trofftable.rc: make work

This commit is contained in:
Humm 2021-04-09 16:05:30 +02:00
parent 1b4758d596
commit a0997f38c4
3 changed files with 1173 additions and 1164 deletions

View file

@ -5,7 +5,8 @@
RESOLUTION=720
UNITWIDTH=10
OCTALESCAPES=${OCTALESCAPES:-160} # <= code means add \0ddd names
if(~ $#OCTALESCAPES 0)
OCTALESCAPES=160 # <= code means add \0ddd names
DOWNLOADVECTOR=FALSE # TRUE can mean incomplete tables
#
@ -16,9 +17,8 @@ DOWNLOADVECTOR=FALSE # TRUE can mean incomplete tables
# font.
#
BuiltinTables() {
cat <<-'//End of BuiltinTables'
Proportional R Times-Roman
fn BuiltinTables {
echo 'Proportional R Times-Roman
Proportional I Times-Italic
Proportional B Times-Bold
Proportional BI Times-BoldItalic
@ -57,15 +57,15 @@ BuiltinTables() {
Greek GR Symbol
Symbol S Symbol
Special S1 Times-Roman
Description DESC ---
//End of BuiltinTables
Proportional CMR12 CMR12
Description DESC ---'
}
#
# AllTables prints the complete list of builtin font names.
#
AllTables() {
fn AllTables {
BuiltinTables | awk '{print $2}'
}
@ -84,16 +84,15 @@ AllTables() {
# flagged with the PostScript comment "% missing".
#
StandardCharset() {
cat <<-'//End of StandardCharset'
(!) /exclam
fn StandardCharset {
echo '(!) /exclam
(") /quotedbl
(dq) (") % synonym
(#) /numbersign
($) /dollar
(%) /percent
(&) /ampersand
(') /quoteright
('') /quoteright
(\() /parenleft
(\)) /parenright
(*) /asterisk
@ -212,7 +211,7 @@ StandardCharset() {
(+-) /plusminus % missing
(2^) /twosuperior % missing
(3^) /threesuperior % missing
(\\') /acute
(\\'') /acute
(aa) (") % devpost synonym
(/u) /mu % missing
(P!) /paragraph
@ -228,7 +227,7 @@ StandardCharset() {
(34) /threequarters % missing
(??) /questiondown
(A`) /Agrave
(A') /Aacute
(A'') /Aacute
(A^) /Acircumflex
(A~) /Atilde
(A") /Adieresis
@ -236,31 +235,31 @@ StandardCharset() {
(AE) /AE
(C,) /Ccedilla
(E`) /Egrave
(E') /Eacute
(E'') /Eacute
(E^) /Ecircumflex
(E") /Edieresis
(I`) /Igrave
(I') /Iacute
(I'') /Iacute
(I^) /Icircumflex
(I") /Idieresis
(D-) /Eth % missing
(N~) /Ntilde
(O`) /Ograve
(O') /Oacute
(O'') /Oacute
(O^) /Ocircumflex
(O~) /Otilde
(O") /Odieresis
(xx) /multiply % missing
(O/) /Oslash
(U`) /Ugrave
(U') /Uacute
(U'') /Uacute
(U^) /Ucircumflex
(U") /Udieresis
(Y') /Yacute % missing
(Y'') /Yacute % missing
(TH) /Thorn % missing
(ss) /germandbls
(a`) /agrave
(a') /aacute
(a'') /aacute
(a^) /acircumflex
(a~) /atilde
(a") /adieresis
@ -268,27 +267,27 @@ StandardCharset() {
(ae) /ae
(c,) /ccedilla
(e`) /egrave
(e') /eacute
(e'') /eacute
(e^) /ecircumflex
(e") /edieresis
(i`) /igrave
(i') /iacute
(i'') /iacute
(i^) /icircumflex
(i") /idieresis
(d-) /eth % missing
(n~) /ntilde
(o`) /ograve
(o') /oacute
(o'') /oacute
(o^) /ocircumflex
(o~) /otilde
(o") /odieresis
(-:) /divide % missing
(o/) /oslash
(u`) /ugrave
(u') /uacute
(u'') /uacute
(u^) /ucircumflex
(u") /udieresis
(y') /yacute % missing
(y'') /yacute % missing
(th) /thorn % missing
(y") /ydieresis
(^a) /circumflex % devpost accent
@ -298,23 +297,21 @@ StandardCharset() {
(oa) /ring % devpost accent
("a) /hungarumlaut % devpost accent
(Ca) /ogonek % devpost accent
(va) /caron % devpost accent
//End of StandardCharset
(va) /caron % devpost accent'
}
#
# DingbatsCharset guarantees changes in StandardCharset don't show up in ZD.
#
DingbatsCharset() {
cat <<-'//End of DingbatsCharset'
(!) /exclam
fn DingbatsCharset {
echo '(!) /exclam
(") /quotedbl
(#) /numbersign
($) /dollar
(%) /percent
(&) /ampersand
(') /quoteright
('') /quoteright
(\() /parenleft
(\)) /parenright
(*) /asterisk
@ -422,7 +419,7 @@ DingbatsCharset() {
(+-) /plusminus % missing
(2^) /twosuperior % missing
(3^) /threesuperior % missing
(\\') /acute
(\\'') /acute
(/u) /mu % missing
(P!) /paragraph
(.^) /periodcentered
@ -435,7 +432,7 @@ DingbatsCharset() {
(34) /threequarters % missing
(??) /questiondown
(A`) /Agrave
(A') /Aacute
(A'') /Aacute
(A^) /Acircumflex
(A~) /Atilde
(A") /Adieresis
@ -443,31 +440,31 @@ DingbatsCharset() {
(AE) /AE
(C,) /Ccedilla
(E`) /Egrave
(E') /Eacute
(E'') /Eacute
(E^) /Ecircumflex
(E") /Edieresis
(I`) /Igrave
(I') /Iacute
(I'') /Iacute
(I^) /Icircumflex
(I") /Idieresis
(D-) /Eth % missing
(N~) /Ntilde
(O`) /Ograve
(O') /Oacute
(O'') /Oacute
(O^) /Ocircumflex
(O~) /Otilde
(O") /Odieresis
(xx) /multiply % missing
(O/) /Oslash
(U`) /Ugrave
(U') /Uacute
(U'') /Uacute
(U^) /Ucircumflex
(U") /Udieresis
(Y') /Yacute % missing
(Y'') /Yacute % missing
(TH) /Thorn % missing
(ss) /germandbls
(a`) /agrave
(a') /aacute
(a'') /aacute
(a^) /acircumflex
(a~) /atilde
(a") /adieresis
@ -475,35 +472,33 @@ DingbatsCharset() {
(ae) /ae
(c,) /ccedilla
(e`) /egrave
(e') /eacute
(e'') /eacute
(e^) /ecircumflex
(e") /edieresis
(i`) /igrave
(i') /iacute
(i'') /iacute
(i^) /icircumflex
(i") /idieresis
(d-) /eth % missing
(n~) /ntilde
(o`) /ograve
(o') /oacute
(o'') /oacute
(o^) /ocircumflex
(o~) /otilde
(o") /odieresis
(-:) /divide % missing
(o/) /oslash
(u`) /ugrave
(u') /uacute
(u'') /uacute
(u^) /ucircumflex
(u") /udieresis
(y') /yacute % missing
(y'') /yacute % missing
(th) /thorn % missing
(y") /ydieresis
//End of DingbatsCharset
(y") /ydieresis'
}
SymbolCharset() {
cat <<-'//End of SymbolCharset'
(---) /exclam
fn SymbolCharset {
echo '(---) /exclam
(fa) /universal
(---) /numbersign
(te) /existential
@ -745,14 +740,12 @@ SymbolCharset() {
(rt) /bracerighttp
(rk) /bracerightmid
(rb) /bracerightbt
(~=) (55 0 1) % charlib
//End of SymbolCharset
(~=) (55 0 1) % charlib'
}
SpecialCharset() {
cat <<-'//End of SpecialCharset'
(ru) /underscore
('') /quotedblright % devpost character
fn SpecialCharset {
echo '(ru) /underscore
('''') /quotedblright % devpost character
(``) /quotedblleft % devpost character
(dg) /dagger % devpost character
(dd) /daggerdbl % devpost character
@ -779,8 +772,7 @@ SpecialCharset() {
(lH) (100 0 1) % charlib
(rH) (100 0 1) % charlib
(PC) (220 2 1) % charlib
(DG) (185 2 1) % charlib
//End of SpecialCharset
(DG) (185 2 1) % charlib'
}
#
@ -791,10 +783,9 @@ SpecialCharset() {
# set appeared sometime after Version 50.0.
#
Latin1() {
if [ "$DOWNLOADVECTOR" = TRUE ]; then
cat <<-'//End of ISOLatin1Encoding'
/ISOLatin1Encoding [
fn Latin1 {
if(~ $"DOWNLOADVECTOR TRUE){
echo ' /ISOLatin1Encoding [
/.notdef
/.notdef
/.notdef
@ -1051,11 +1042,10 @@ Latin1() {
/yacute
/thorn
/ydieresis
] def
//End of ISOLatin1Encoding
fi
] def'
}
echo "ISOLatin1Encoding /$1 ReEncode"
echo 'ISOLatin1Encoding /'^$1^' ReEncode'
}
#
@ -1066,11 +1056,11 @@ Latin1() {
# all available.
#
Proportional() {
echo "/unitwidth $UNITWIDTH def"
echo "/resolution $RESOLUTION def"
echo "/octalescapes $OCTALESCAPES def"
echo "/charset ["
fn Proportional {
echo /unitwidth $UNITWIDTH def
echo /resolution $RESOLUTION def
echo /octalescapes $OCTALESCAPES def
echo '/charset ['
# Get <>_ and | from S. Use accents for ascii ^ and ~.
StandardCharset | awk '
$1 == "(<)" && $2 == "/less" {$1 = "(---)"}
@ -1087,118 +1077,118 @@ Proportional() {
}
{printf "%s\t%s\n", $1, $2}
'
echo "] def"
echo '] def'
Latin1 $2
echo "/$2 SelectFont"
echo "(opO) SetAscender"
echo /$2 SelectFont
echo '(opO) SetAscender'
echo "(name $1\\\\n) Print"
echo "(fontname $2\\\\n) Print"
echo "/$1 NamedInPrologue"
echo "(spacewidth ) Print 32 GetWidth Print (\n) Print"
echo "(charset\\\\n) Print"
echo "BuildFontCharset"
echo '(name '^$1^'\n) Print'
echo '(fontname '^$2^'\n) Print'
echo /$1 NamedInPrologue
echo '(spacewidth ) Print 32 GetWidth Print (\n) Print'
echo '(charset\n) Print'
echo BuildFontCharset
}
FixedWidth() {
echo "/unitwidth $UNITWIDTH def"
echo "/resolution $RESOLUTION def"
echo "/octalescapes $OCTALESCAPES def"
echo "/charset ["
fn FixedWidth {
echo '/unitwidth $UNITWIDTH def'
echo '/resolution $RESOLUTION def'
echo '/octalescapes $OCTALESCAPES def'
echo '/charset ['
StandardCharset
echo "] def"
echo '] def'
Latin1 $2
echo "/$2 SelectFont"
echo "(opO) SetAscender"
echo /$2 SelectFont
echo '(opO) SetAscender'
echo "(name $1\\\\n) Print"
echo "(fontname $2\\\\n) Print"
echo "/$1 NamedInPrologue"
echo "(spacewidth ) Print 32 GetWidth Print (\n) Print"
echo "(charset\\\\n) Print"
echo "BuildFontCharset"
echo '(name '^$1^'\n) Print'
echo '(fontname '^$2^'\n) Print'
echo /$1 NamedInPrologue
echo '(spacewidth ) Print 32 GetWidth Print (\n) Print'
echo '(charset\n) Print'
echo BuildFontCharset
}
Dingbats() {
echo "/unitwidth $UNITWIDTH def"
echo "/resolution $RESOLUTION def"
echo "/octalescapes $OCTALESCAPES def"
echo "/charset ["
fn Dingbats {
echo '/unitwidth $UNITWIDTH def'
echo '/resolution $RESOLUTION def'
echo '/octalescapes $OCTALESCAPES def'
echo '/charset ['
DingbatsCharset | awk '$1 != "(---)" && $2 ~ /^\/[a-zA-Z]/ {
printf "%s\tISOLatin1Encoding %s GetCode\n", $1, $2
}'
echo "] def"
echo '] def'
echo "/$2 SelectFont"
echo "( ) SetAscender"
echo /$2 SelectFont
echo '( ) SetAscender'
echo "(name $1\\\\n) Print"
echo "(fontname $2\\\\n) Print"
echo "/$1 NamedInPrologue"
echo "(charset\\\\n) Print"
echo "BuildFontCharset"
echo '(name '^$1^'\n) Print'
echo '(fontname '^$2^'\n) Print'
echo /$1 NamedInPrologue
echo '(charset\n) Print'
echo BuildFontCharset
}
Greek() {
echo "/unitwidth $UNITWIDTH def"
echo "/resolution $RESOLUTION def"
echo "/charset ["
fn Greek {
echo /unitwidth $UNITWIDTH def
echo /resolution $RESOLUTION def
echo /charset [
SymbolCharset | awk '
BEGIN {hit = -1}
$1 ~ /\(\*[a-zA-Z]\)/ {print; hit = NR}
$2 == "(\")" && hit == NR-1 {print; hit = NR}
'
echo "] def"
echo ] def
echo "/$2 SelectFont"
echo "(orO) SetAscender"
echo /$2 SelectFont
echo '(orO) SetAscender'
echo "(name $1\\\\n) Print"
echo "(fontname $2\\\\n) Print"
echo "/$1 NamedInPrologue"
echo "(spacewidth ) Print 32 GetWidth Print (\n) Print"
echo "(charset\\\\n) Print"
echo "BuildFontCharset"
echo '(name '^$1^'\n) Print'
echo '(fontname '^$2^'\n) Print'
echo /$1 NamedInPrologue
echo '(spacewidth ) Print 32 GetWidth Print (\n) Print'
echo '(charset\n) Print'
echo BuildFontCharset
}
Symbol() {
echo "/unitwidth $UNITWIDTH def"
echo "/resolution $RESOLUTION def"
echo "/charset ["
fn Symbol {
echo /unitwidth $UNITWIDTH def
echo /resolution $RESOLUTION def
echo /charset [
SymbolCharset
echo "] def"
echo ] def
echo "ChangeMetrics"
echo "/S SelectFont"
echo "(orO) SetAscender"
echo ChangeMetrics
echo /S SelectFont
echo '(orO) SetAscender'
echo "(name $1\\\\n) Print"
echo "(fontname $2\\\\n) Print"
echo "/$1 NamedInPrologue"
echo "(special\\\\n) Print"
echo "(charset\\\\n) Print"
echo "BuildFontCharset"
echo '(name '^$1^'\n) Print'
echo '(fontname '^$2^'\n) Print'
echo /$1 NamedInPrologue
echo '(special\n) Print'
echo '(charset\n) Print'
echo BuildFontCharset
}
Special() {
echo "/unitwidth $UNITWIDTH def"
echo "/resolution $RESOLUTION def"
echo "/charset ["
fn Special {
echo /unitwidth $UNITWIDTH def
echo /resolution $RESOLUTION def
echo /charset [
SpecialCharset
echo "] def"
echo ] def
echo "ChangeMetrics"
echo "/S1 SelectFont"
echo ChangeMetrics
echo /S1 SelectFont
echo "(# Times-Roman special font\\\\n) Print"
echo "(name $1\\\\n) Print"
echo "(fontname $2\\\\n) Print"
echo "/$1 NamedInPrologue"
echo "(special\\\\n) Print"
echo "(charset\\\\n) Print"
echo "BuildFontCharset"
echo '(# Times-Roman special font\n) Print'
echo '(name '^$1^'\n) Print'
echo '(fontname '^$2^'\n) Print'
echo /$1 NamedInPrologue
echo '(special\n) Print'
echo '(charset\n) Print'
echo BuildFontCharset
}
#
@ -1206,15 +1196,14 @@ Special() {
# consistency.
#
Description() {
echo "/charset [" # awk - so the stack doesn't overflow
fn Description {
echo /charset [ # awk - so the stack doesn't overflow
StandardCharset | awk '$1 !~ /\(\\[0-9]/ {print $1}'
SymbolCharset | awk '$1 !~ /\(\\[0-9]/ {print $1}'
SpecialCharset | awk '$1 !~ /\(\\[0-9]/ {print $1}'
echo "] def"
echo ] def
cat <<-//DESC
(#Device Description - utf character set
echo '(#Device Description - utf character set
PDL PostScript
Encoding Latin1
@ -1229,10 +1218,9 @@ Description() {
vert 1
unitwidth $UNITWIDTH
) Print
//DESC
echo "(charset\\\\n) Print"
echo "BuildDescCharset"
echo "(\\\\n) Print"
) Print'
echo '(charset\n) Print'
echo BuildDescCharset
echo '(\n) Print'
}

View file

@ -1,46 +1,63 @@
.ds dF /usr/lib/font
.ds dQ /usr/lib/postscript
.TH TROFFTABLE 1 "DWB 3.2"
.ds dF /sys/lib/troff/font
.ds dQ /sys/lib/postscript/prologues
.TH TROFFTABLE 1
.SH NAME
.B trofftable
\- output a PostScript program that builds a font width table
trofftable \- output a PostScript program that builds a font width table
.SH SYNOPSIS
\*(mBtrofftable\f1
.OP "" options []
.OP "" shortname
.OP "" longname []
.SH DESCRIPTION
.B trofftable
[
.B -t
.I name
] [
.B -C
.I file
] [
.B -H
.I hostdir
] [
.B -L
.I file
] [
.B -S
.I file
] [
.B -T
.I name
]
.I shortname
[
.I longname
]
.SH DESCRIPTION
.I Trofftable
writes a PostScript program on the standard output that builds a
font width table or typesetter description file.
The following
.I options
are understood:
.TP 1.0i
.OP \-t name
The following options are understood:
.TP
.BI -t " name"
Use
.I name
as the template for fonts not in the default set.
Choose
.MW R
.B R
for proportionally spaced fonts and
.MW CW
.B CW
for fixed width fonts.
Try
.MW ZD
.B ZD
(ZapfDingbats) if the font has a non-standard
character set.
The default is
.MR R .
.TP 1.0i
.OP \-C file
.BR R .
.TP
.BI -C " file"
Copy
.I file
into each PostScript table program;
.I file
must contain legitimate PostScript.
.TP 1.0i
.OP \-H hostdir
.TP
.BI -H " hostdir"
Use
.I hostdir
as the host resident font directory.
@ -50,55 +67,55 @@ that matches the name of the troff font is assumed to be a host
resident font program and is included in the PostScript width
table program.
There is no default.
.TP 1.0i
.OP \-L file
.TP
.BI -L " file"
Use
.I file
as the PostScript prologue.
.br
The default is
.MW \*(dQ/trofftable.ps
.TP 1.0i
.OP \-S file
.B \*(dQ/trofftable.ps
.TP
.BI -S " file"
Use
.I file
as the shell library file.
Overrides the choice made with the
.OP \-T
.B -T
option.
.TP 1.0i
.OP \-T name
.TP
.BI -T " name"
Set the target device to
.IR name .
Device
.I name
means
.br
.MI \*(dF/dev name /shell.lib
.BI \*(dF/dev name /shell.lib
is the shell library file.
There is no default.
.PP
One of
.OP \-T
.B -T
or
.OP \-S
.B -S
is required.
If both are given
.OP \-S
.B -S
wins.
Either
.OP \-H
.B -H
or
.OP \-C
.B -C
can be used to include a host resident font.
.PP
The shell library file defines a collection of functions used to
build troff tables.
The default set of tables is the list of names returned by the
.MW AllTables
.B AllTables
function.
Changes to the default list can be made by updating the
.MW BuiltinTables
.B BuiltinTables
function.
.PP
.I Shortname
@ -112,16 +129,16 @@ can be omitted only if
.I shortname
is a default table name.
PostScript table programs created by
.B trofftable
.I trofftable
return data to the host computer using PostScript's
.MW print
.B print
operator.
See
.BR hardcopy (1)
.IR hardcopy (1)
if you don't have access to the printer's serial port.
.SH EXAMPLES
Get the PostScript program that builds a width table for font
.MR R :
.BR R :
.EX
trofftable -Tpost R >R.ps
.EE
@ -133,32 +150,32 @@ trofftable -TLatin1 GL Garamond-Light >GL.ps
.EE
A font must be available on the printer when the table is built.
Use
.OP \-H
.B -H
or
.OP \-C
.B -C
to include host resident fonts.
.SH WARNINGS
A width table will not build properly if the printer cannot access
the PostScript font.
.PP
The
.OP -TLatin1
.B -TLatin1
option only works on PostScript printers that support the full
.SM ISO
Latin-1 character set.
The error message from older printers will likely indicate a missing
.MW ISOLatin1Encoding
.B ISOLatin1Encoding
array.
.SH FILES
.MW \*(dF/dev*/shell.lib
.B \*(dF/dev*/shell.lib
.br
.MW \*(dQ/dpost.ps
.B \*(dQ/dpost.ps
.br
.MW \*(dQ/trofftable.ps
.B \*(dQ/trofftable.ps
.SH SEE ALSO
.BR dpost (1),
.BR hardcopy (1),
.BR postio (1),
.BR troff (1),
.BR buildtables (1),
.BR font (5)
.IR dpost (1),
.IR hardcopy (1),
.IR postio (1),
.IR troff (1),
.IR buildtables (1),
.IR font (5)

View file

@ -5,6 +5,8 @@
# serial port. Try hardcopy if you don't have access to the port.
#
rfork e
POSTLIB=/sys/lib/postscript/prologues
FONTDIR=/sys/lib/troff/font
@ -15,7 +17,7 @@ COPYFILE=()
HOSTFONTDIR=()
DEVICE=()
LIBRARY=()
TEMPLATE=-R
TEMPLATE=R
SLOWDOWN=25
STARTCOMMENTS=256
@ -28,8 +30,8 @@ TRAILER='%%Trailer'
while (! ~ $#* 0 && ~ $1 -*) {
switch ($1) {
case -C; shift; COPYFILE=$COPYFILE' '$1
case -C*; COPYFILE=$COPYFILE' '`{echo $1 | sed s/-C//}
case -C; shift; COPYFILE=($COPYFILE $1)
case -C*; COPYFILE=($COPYFILE `{echo $1 | sed s/-C//})
case -F; shift; FONTDIR=$1
case -F*; FONTDIR=`{echo $1 | sed s/-F//}
@ -63,7 +65,7 @@ while (! ~ $#* 0 && ~ $1 -*) {
shift
}
if (! ~ $#DEVICE 0 && ! ~ $#LIBRARY 0) {
if (~ $#DEVICE 0 && ~ $#LIBRARY 0) {
echo $0: no device or shell library >[1=2]
exit 1
}
@ -73,28 +75,31 @@ if (! ~ $#* 1 2) {
exit 1
}
if (test -d $HOSTFONTDIR -a -f $HOSTFONTDIR/$1) {
COPYFILE=$COPYFILE' '$HOSTFONTDIR/$1
if (! ~ $#HOSTFONTDIR 0 && test -d $HOSTFONTDIR -a -f $HOSTFONTDIR/$1) {
COPYFILE=($COPYFILE $HOSTFONTDIR/$1)
}
#
# Include the shell library and get the command used to build the table.
# Make awk call a separate library function??
#
if (~ $#LIBRARY 0 || ~ $LIBRARY '') LIBRARY=$FONTDIR/dev$DEVICE/shell.lib
if (~ $#LIBRARY 0) LIBRARY=$FONTDIR/dev$DEVICE/shell.lib
. $LIBRARY
if (~ $#* 1) TEMPLATE=$1
if (~ $#* 2) pname=$2
if not pname=''
CMD=`{BuiltinTables | awk '$2 == template"" {
if ( pname == "" )
pname = $3
printf "%s %s %s", $1, tname, pname
exit 0
}' template=$TEMPLATE tname=$1 pname=$2}
}' 'template='$TEMPLATE 'tname='$1 'pname='$pname}
if (! $CMD) {
if (~ $#CMD 0) {
echo $0: $TEMPLATE not found >[1=2]
exit 1
}
@ -111,7 +116,7 @@ echo end def
echo $ENDPROLOG
echo $BEGINSETUP
if (~ $COPYFILE '') COPYFILE=/dev/null
if (! ~ $#COPYFILE 0)
cat $COPYFILE
echo /slowdown $SLOWDOWN def
echo /startcomments $STARTCOMMENTS def
@ -120,4 +125,3 @@ echo $ENDSETUP
$CMD
echo $TRAILER