aboutsummaryrefslogtreecommitdiffstats
path: root/troff/troff.d
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2016-10-06 21:30:09 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2016-10-06 21:30:09 +0000
commitaa7798c94fa57f6c00fab4393c9fe91334864371 (patch)
tree61b5a60e9c086b1ba44b4718e7666304a8edab6f /troff/troff.d
downloadsrc-aa7798c94fa57f6c00fab4393c9fe91334864371.tar.gz
src-aa7798c94fa57f6c00fab4393c9fe91334864371.zip
Import heirloom doctools snapshot from git as of 161006vendor/heirloom-doctools/20161006
Notes
Notes: svn path=/vendor/heirloom-doctools/dist/; revision=306788 svn path=/vendor/heirloom-doctools/20161006/; revision=306789; tag=vendor/heirloom-doctools/20161006
Diffstat (limited to 'troff/troff.d')
-rw-r--r--troff/troff.d/Makefile.mk66
-rw-r--r--troff/troff.d/README184
-rw-r--r--troff/troff.d/afm.c1201
-rw-r--r--troff/troff.d/afm.h149
-rw-r--r--troff/troff.d/dev.h104
-rw-r--r--troff/troff.d/devaps/B148
-rw-r--r--troff/troff.d/devaps/BI139
-rw-r--r--troff/troff.d/devaps/C139
-rw-r--r--troff/troff.d/devaps/CE139
-rw-r--r--troff/troff.d/devaps/CI139
-rw-r--r--troff/troff.d/devaps/CT132
-rw-r--r--troff/troff.d/devaps/CW147
-rw-r--r--troff/troff.d/devaps/CX140
-rw-r--r--troff/troff.d/devaps/DESC67
-rw-r--r--troff/troff.d/devaps/G139
-rw-r--r--troff/troff.d/devaps/GB90
-rw-r--r--troff/troff.d/devaps/GI141
-rw-r--r--troff/troff.d/devaps/GR89
-rw-r--r--troff/troff.d/devaps/GS135
-rw-r--r--troff/troff.d/devaps/H139
-rw-r--r--troff/troff.d/devaps/HB139
-rw-r--r--troff/troff.d/devaps/HI141
-rw-r--r--troff/troff.d/devaps/HK140
-rw-r--r--troff/troff.d/devaps/HL139
-rw-r--r--troff/troff.d/devaps/HX140
-rw-r--r--troff/troff.d/devaps/I148
-rw-r--r--troff/troff.d/devaps/MB139
-rw-r--r--troff/troff.d/devaps/MI139
-rw-r--r--troff/troff.d/devaps/MR139
-rw-r--r--troff/troff.d/devaps/MX139
-rw-r--r--troff/troff.d/devaps/Makefile.mk48
-rw-r--r--troff/troff.d/devaps/PA139
-rw-r--r--troff/troff.d/devaps/PB139
-rw-r--r--troff/troff.d/devaps/PI139
-rw-r--r--troff/troff.d/devaps/PO147
-rw-r--r--troff/troff.d/devaps/PX140
-rw-r--r--troff/troff.d/devaps/R148
-rw-r--r--troff/troff.d/devaps/README102
-rw-r--r--troff/troff.d/devaps/S127
-rw-r--r--troff/troff.d/devaps/S174
-rw-r--r--troff/troff.d/devaps/SC135
-rw-r--r--troff/troff.d/devaps/SM134
-rw-r--r--troff/troff.d/devaps/TB139
-rw-r--r--troff/troff.d/devaps/TX140
-rw-r--r--troff/troff.d/devaps/aps.h136
-rw-r--r--troff/troff.d/devaps/build.c323
-rw-r--r--troff/troff.d/devaps/daps.c2995
-rw-r--r--troff/troff.d/devaps/daps.g219
-rw-r--r--troff/troff.d/devaps/daps.h461
-rw-r--r--troff/troff.d/devaps/dev.h81
-rw-r--r--troff/troff.d/devaps/draw.c3
-rw-r--r--troff/troff.d/devaps/getopt.c222
-rw-r--r--troff/troff.d/devaps/makedev.c650
-rw-r--r--troff/troff.d/devaps/version34
-rw-r--r--troff/troff.d/devaps/version.c19
-rw-r--r--troff/troff.d/dhtml/Makefile.mk29
-rw-r--r--troff/troff.d/dhtml/char.c115
-rw-r--r--troff/troff.d/dhtml/char.h15
-rw-r--r--troff/troff.d/dhtml/dhtml.1107
-rw-r--r--troff/troff.d/dhtml/dhtml.h1
-rw-r--r--troff/troff.d/dhtml/dhtml.l87
-rw-r--r--troff/troff.d/dhtml/lib.c148
-rw-r--r--troff/troff.d/dhtml/lib.h9
-rw-r--r--troff/troff.d/dhtml/main.c79
-rw-r--r--troff/troff.d/dhtml/main.h1
-rw-r--r--troff/troff.d/dhtml/roff.c27
-rw-r--r--troff/troff.d/dhtml/roff.h2
-rw-r--r--troff/troff.d/dhtml/tr_out.c221
-rw-r--r--troff/troff.d/dhtml/tr_out.h17
-rw-r--r--troff/troff.d/dpost.d/Makefile.mk42
-rw-r--r--troff/troff.d/dpost.d/README53
-rw-r--r--troff/troff.d/dpost.d/afm.c32
-rw-r--r--troff/troff.d/dpost.d/asciitype.c59
-rw-r--r--troff/troff.d/dpost.d/asciitype.h60
-rw-r--r--troff/troff.d/dpost.d/color.c275
-rw-r--r--troff/troff.d/dpost.d/comments.h161
-rw-r--r--troff/troff.d/dpost.d/dpost.1258
-rw-r--r--troff/troff.d/dpost.d/dpost.c4836
-rw-r--r--troff/troff.d/dpost.d/dpost.h192
-rw-r--r--troff/troff.d/dpost.d/draw.c844
-rw-r--r--troff/troff.d/dpost.d/ext.h54
-rw-r--r--troff/troff.d/dpost.d/gen.h174
-rw-r--r--troff/troff.d/dpost.d/getopt.c222
-rw-r--r--troff/troff.d/dpost.d/glob.c56
-rw-r--r--troff/troff.d/dpost.d/makedev.c29
-rw-r--r--troff/troff.d/dpost.d/misc.c395
-rw-r--r--troff/troff.d/dpost.d/otf.c36
-rw-r--r--troff/troff.d/dpost.d/path.h61
-rw-r--r--troff/troff.d/dpost.d/pictures.c364
-rw-r--r--troff/troff.d/dpost.d/ps_include.c361
-rw-r--r--troff/troff.d/dpost.d/request.c182
-rw-r--r--troff/troff.d/dpost.d/request.h58
-rw-r--r--troff/troff.d/dpost.d/version.c3
-rw-r--r--troff/troff.d/draw.c497
-rw-r--r--troff/troff.d/font/Makefile.mk57
-rw-r--r--troff/troff.d/font/README139
-rw-r--r--troff/troff.d/font/devhtml/B2
-rw-r--r--troff/troff.d/font/devhtml/BI2
-rw-r--r--troff/troff.d/font/devhtml/C2
-rw-r--r--troff/troff.d/font/devhtml/CB2
-rw-r--r--troff/troff.d/font/devhtml/CHAR121
-rw-r--r--troff/troff.d/font/devhtml/CI2
-rw-r--r--troff/troff.d/font/devhtml/CR2
-rw-r--r--troff/troff.d/font/devhtml/CW2
-rw-r--r--troff/troff.d/font/devhtml/DESC7
-rw-r--r--troff/troff.d/font/devhtml/H2
-rw-r--r--troff/troff.d/font/devhtml/HB2
-rw-r--r--troff/troff.d/font/devhtml/HI2
-rw-r--r--troff/troff.d/font/devhtml/I2
-rw-r--r--troff/troff.d/font/devhtml/Makefile.mk23
-rw-r--r--troff/troff.d/font/devhtml/R2
-rw-r--r--troff/troff.d/font/devhtml/S2
-rw-r--r--troff/troff.d/font/devhtml/charset90
-rw-r--r--troff/troff.d/font/devhtml/makefont.c195
-rw-r--r--troff/troff.d/font/devpost/AB125
-rw-r--r--troff/troff.d/font/devpost/AB.name1
-rw-r--r--troff/troff.d/font/devpost/AI125
-rw-r--r--troff/troff.d/font/devpost/AI.name1
-rw-r--r--troff/troff.d/font/devpost/AR125
-rw-r--r--troff/troff.d/font/devpost/AR.name1
-rw-r--r--troff/troff.d/font/devpost/AX125
-rw-r--r--troff/troff.d/font/devpost/AX.name1
-rw-r--r--troff/troff.d/font/devpost/B137
-rw-r--r--troff/troff.d/font/devpost/B.name1
-rw-r--r--troff/troff.d/font/devpost/BI133
-rw-r--r--troff/troff.d/font/devpost/BI.name1
-rw-r--r--troff/troff.d/font/devpost/CB137
-rw-r--r--troff/troff.d/font/devpost/CB.name1
-rw-r--r--troff/troff.d/font/devpost/CI145
-rw-r--r--troff/troff.d/font/devpost/CI.name1
-rw-r--r--troff/troff.d/font/devpost/CO137
-rw-r--r--troff/troff.d/font/devpost/CO.name1
-rw-r--r--troff/troff.d/font/devpost/CW145
-rw-r--r--troff/troff.d/font/devpost/CW.name1
-rw-r--r--troff/troff.d/font/devpost/CX145
-rw-r--r--troff/troff.d/font/devpost/CX.name1
-rw-r--r--troff/troff.d/font/devpost/DESC63
-rw-r--r--troff/troff.d/font/devpost/DESC.big48
-rw-r--r--troff/troff.d/font/devpost/DESC.small52
-rw-r--r--troff/troff.d/font/devpost/FONTMAP21
-rw-r--r--troff/troff.d/font/devpost/GR83
-rw-r--r--troff/troff.d/font/devpost/GR.name1
-rw-r--r--troff/troff.d/font/devpost/H133
-rw-r--r--troff/troff.d/font/devpost/H.name1
-rw-r--r--troff/troff.d/font/devpost/HB133
-rw-r--r--troff/troff.d/font/devpost/HB.name1
-rw-r--r--troff/troff.d/font/devpost/HI133
-rw-r--r--troff/troff.d/font/devpost/HI.name1
-rw-r--r--troff/troff.d/font/devpost/HNB125
-rw-r--r--troff/troff.d/font/devpost/HNB.name1
-rw-r--r--troff/troff.d/font/devpost/HNBI125
-rw-r--r--troff/troff.d/font/devpost/HNBI.name1
-rw-r--r--troff/troff.d/font/devpost/HNI125
-rw-r--r--troff/troff.d/font/devpost/HNI.name1
-rw-r--r--troff/troff.d/font/devpost/HNR125
-rw-r--r--troff/troff.d/font/devpost/HNR.name1
-rw-r--r--troff/troff.d/font/devpost/HX133
-rw-r--r--troff/troff.d/font/devpost/HX.name1
-rw-r--r--troff/troff.d/font/devpost/I137
-rw-r--r--troff/troff.d/font/devpost/I.name1
-rw-r--r--troff/troff.d/font/devpost/KB125
-rw-r--r--troff/troff.d/font/devpost/KB.name1
-rw-r--r--troff/troff.d/font/devpost/KI125
-rw-r--r--troff/troff.d/font/devpost/KI.name1
-rw-r--r--troff/troff.d/font/devpost/KR125
-rw-r--r--troff/troff.d/font/devpost/KR.name1
-rw-r--r--troff/troff.d/font/devpost/KX125
-rw-r--r--troff/troff.d/font/devpost/KX.name1
-rw-r--r--troff/troff.d/font/devpost/NB125
-rw-r--r--troff/troff.d/font/devpost/NB.name1
-rw-r--r--troff/troff.d/font/devpost/NI125
-rw-r--r--troff/troff.d/font/devpost/NI.name1
-rw-r--r--troff/troff.d/font/devpost/NR125
-rw-r--r--troff/troff.d/font/devpost/NR.name1
-rw-r--r--troff/troff.d/font/devpost/NX125
-rw-r--r--troff/troff.d/font/devpost/NX.name1
-rw-r--r--troff/troff.d/font/devpost/PA133
-rw-r--r--troff/troff.d/font/devpost/PA.name1
-rw-r--r--troff/troff.d/font/devpost/PB133
-rw-r--r--troff/troff.d/font/devpost/PB.name1
-rw-r--r--troff/troff.d/font/devpost/PI133
-rw-r--r--troff/troff.d/font/devpost/PI.name1
-rw-r--r--troff/troff.d/font/devpost/PX133
-rw-r--r--troff/troff.d/font/devpost/PX.name1
-rw-r--r--troff/troff.d/font/devpost/R137
-rw-r--r--troff/troff.d/font/devpost/R.name1
-rw-r--r--troff/troff.d/font/devpost/S236
-rw-r--r--troff/troff.d/font/devpost/S.big228
-rw-r--r--troff/troff.d/font/devpost/S.name1
-rw-r--r--troff/troff.d/font/devpost/S.small155
-rw-r--r--troff/troff.d/font/devpost/S164
-rw-r--r--troff/troff.d/font/devpost/S1.name1
-rw-r--r--troff/troff.d/font/devpost/VB129
-rw-r--r--troff/troff.d/font/devpost/VB.name1
-rw-r--r--troff/troff.d/font/devpost/VI129
-rw-r--r--troff/troff.d/font/devpost/VI.name1
-rw-r--r--troff/troff.d/font/devpost/VR129
-rw-r--r--troff/troff.d/font/devpost/VR.name1
-rw-r--r--troff/troff.d/font/devpost/VX129
-rw-r--r--troff/troff.d/font/devpost/VX.name1
-rw-r--r--troff/troff.d/font/devpost/ZD214
-rw-r--r--troff/troff.d/font/devpost/ZD.name1
-rw-r--r--troff/troff.d/font/devpost/ZI125
-rw-r--r--troff/troff.d/font/devpost/ZI.name1
-rw-r--r--troff/troff.d/font/devpost/charlib/1244
-rw-r--r--troff/troff.d/font/devpost/charlib/1444
-rw-r--r--troff/troff.d/font/devpost/charlib/3444
-rw-r--r--troff/troff.d/font/devpost/charlib/BRACKETS_NOTE58
-rw-r--r--troff/troff.d/font/devpost/charlib/Fi30
-rw-r--r--troff/troff.d/font/devpost/charlib/Fl30
-rw-r--r--troff/troff.d/font/devpost/charlib/L138
-rw-r--r--troff/troff.d/font/devpost/charlib/L1.map150
-rw-r--r--troff/troff.d/font/devpost/charlib/LH.map871
-rw-r--r--troff/troff.d/font/devpost/charlib/LH_uc27
-rw-r--r--troff/troff.d/font/devpost/charlib/Lb38
-rw-r--r--troff/troff.d/font/devpost/charlib/Lb.map150
-rw-r--r--troff/troff.d/font/devpost/charlib/OLD_LH34
-rw-r--r--troff/troff.d/font/devpost/charlib/OLD_LH.map150
-rw-r--r--troff/troff.d/font/devpost/charlib/README47
-rw-r--r--troff/troff.d/font/devpost/charlib/Sl131
-rw-r--r--troff/troff.d/font/devpost/charlib/bx38
-rw-r--r--troff/troff.d/font/devpost/charlib/ci34
-rw-r--r--troff/troff.d/font/devpost/charlib/ff30
-rw-r--r--troff/troff.d/font/devpost/charlib/lc61
-rw-r--r--troff/troff.d/font/devpost/charlib/lf61
-rw-r--r--troff/troff.d/font/devpost/charlib/lh193
-rw-r--r--troff/troff.d/font/devpost/charlib/ob34
-rw-r--r--troff/troff.d/font/devpost/charlib/rc61
-rw-r--r--troff/troff.d/font/devpost/charlib/rf61
-rw-r--r--troff/troff.d/font/devpost/charlib/rh184
-rw-r--r--troff/troff.d/font/devpost/charlib/sq42
-rw-r--r--troff/troff.d/font/devpost/charlib/~=30
-rw-r--r--troff/troff.d/font/devps/B1
-rw-r--r--troff/troff.d/font/devps/B.afm1331
-rw-r--r--troff/troff.d/font/devps/BI1
-rw-r--r--troff/troff.d/font/devps/BI.afm1264
-rw-r--r--troff/troff.d/font/devps/CB1
-rw-r--r--troff/troff.d/font/devps/CB.afm256
-rw-r--r--troff/troff.d/font/devps/CI1
-rw-r--r--troff/troff.d/font/devps/CI.afm256
-rw-r--r--troff/troff.d/font/devps/CW1
-rw-r--r--troff/troff.d/font/devps/CW.afm256
-rw-r--r--troff/troff.d/font/devps/CX1
-rw-r--r--troff/troff.d/font/devps/CX.afm256
-rw-r--r--troff/troff.d/font/devps/DESC62
-rw-r--r--troff/troff.d/font/devps/FONTMAP2
-rw-r--r--troff/troff.d/font/devps/H1
-rw-r--r--troff/troff.d/font/devps/H.afm1558
-rw-r--r--troff/troff.d/font/devps/HB1
-rw-r--r--troff/troff.d/font/devps/HB.afm1441
-rw-r--r--troff/troff.d/font/devps/HI1
-rw-r--r--troff/troff.d/font/devps/HI.afm1558
-rw-r--r--troff/troff.d/font/devps/HX1
-rw-r--r--troff/troff.d/font/devps/HX.afm1441
-rw-r--r--troff/troff.d/font/devps/I1
-rw-r--r--troff/troff.d/font/devps/I.afm1298
-rw-r--r--troff/troff.d/font/devps/MustRead.html19
-rw-r--r--troff/troff.d/font/devps/R1
-rw-r--r--troff/troff.d/font/devps/R.afm1271
-rw-r--r--troff/troff.d/font/devps/S2
-rw-r--r--troff/troff.d/font/devps/S.afm214
-rw-r--r--troff/troff.d/font/devps/S12
-rw-r--r--troff/troff.d/font/devps/S1.afm51
-rw-r--r--troff/troff.d/font/devps/ZD1
-rw-r--r--troff/troff.d/font/devps/ZD.afm226
-rw-r--r--troff/troff.d/font/devpslow/DESC60
-rw-r--r--troff/troff.d/font/devpsmed/DESC61
-rw-r--r--troff/troff.d/fontmap.c158
-rw-r--r--troff/troff.d/fontmap.h2
-rw-r--r--troff/troff.d/makedev.c491
-rw-r--r--troff/troff.d/otf.c3597
-rw-r--r--troff/troff.d/otfdump.143
-rw-r--r--troff/troff.d/otfdump.c216
-rw-r--r--troff/troff.d/otfdump_vs.c3
-rw-r--r--troff/troff.d/postscript/Makefile.mk12
-rw-r--r--troff/troff.d/postscript/aps.ps154
-rw-r--r--troff/troff.d/postscript/baseline.ps183
-rw-r--r--troff/troff.d/postscript/color.ps93
-rw-r--r--troff/troff.d/postscript/cutmarks.ps260
-rw-r--r--troff/troff.d/postscript/dpost.ps285
-rw-r--r--troff/troff.d/postscript/draw.ps124
-rw-r--r--troff/troff.d/postscript/fatcourier.ps53
-rw-r--r--troff/troff.d/postscript/forms.ps223
-rw-r--r--troff/troff.d/postscript/ps.requests36
-rw-r--r--troff/troff.d/postscript/ps_include.ps139
-rw-r--r--troff/troff.d/pt.h96
-rw-r--r--troff/troff.d/t10.c1139
-rw-r--r--troff/troff.d/t6.c3032
-rw-r--r--troff/troff.d/ta.c886
-rw-r--r--troff/troff.d/tmac.d/Makefile.mk32
-rw-r--r--troff/troff.d/tmac.d/acm.me88
-rw-r--r--troff/troff.d/tmac.d/an-ext104
-rw-r--r--troff/troff.d/tmac.d/an.in647
-rw-r--r--troff/troff.d/tmac.d/andoc.in66
-rw-r--r--troff/troff.d/tmac.d/bib.in251
-rw-r--r--troff/troff.d/tmac.d/chars.me86
-rw-r--r--troff/troff.d/tmac.d/color58
-rw-r--r--troff/troff.d/tmac.d/deltext.me53
-rw-r--r--troff/troff.d/tmac.d/doc-common489
-rw-r--r--troff/troff.d/tmac.d/doc-ditroff.in192
-rw-r--r--troff/troff.d/tmac.d/doc-nroff150
-rw-r--r--troff/troff.d/tmac.d/doc-syms492
-rw-r--r--troff/troff.d/tmac.d/doc.in4264
-rw-r--r--troff/troff.d/tmac.d/e.in1051
-rw-r--r--troff/troff.d/tmac.d/eqn.me110
-rw-r--r--troff/troff.d/tmac.d/float.me93
-rw-r--r--troff/troff.d/tmac.d/footnote.me116
-rw-r--r--troff/troff.d/tmac.d/g.in237
-rw-r--r--troff/troff.d/tmac.d/index.me134
-rw-r--r--troff/troff.d/tmac.d/local.me43
-rw-r--r--troff/troff.d/tmac.d/m.in40
-rw-r--r--troff/troff.d/tmac.d/man.71220
-rw-r--r--troff/troff.d/tmac.d/mcolor.7121
-rw-r--r--troff/troff.d/tmac.d/mdoc.74280
-rw-r--r--troff/troff.d/tmac.d/mmn2832
-rw-r--r--troff/troff.d/tmac.d/mmt2850
-rw-r--r--troff/troff.d/tmac.d/mpictures.7188
-rw-r--r--troff/troff.d/tmac.d/ms.acc116
-rw-r--r--troff/troff.d/tmac.d/ms.cov298
-rw-r--r--troff/troff.d/tmac.d/ms.eqn91
-rw-r--r--troff/troff.d/tmac.d/ms.ref192
-rw-r--r--troff/troff.d/tmac.d/ms.tbl116
-rw-r--r--troff/troff.d/tmac.d/ms.ths53
-rw-r--r--troff/troff.d/tmac.d/ms.toc106
-rw-r--r--troff/troff.d/tmac.d/naa115
-rw-r--r--troff/troff.d/tmac.d/null.me36
-rw-r--r--troff/troff.d/tmac.d/padj2
-rw-r--r--troff/troff.d/tmac.d/pictures169
-rw-r--r--troff/troff.d/tmac.d/pm.in975
-rw-r--r--troff/troff.d/tmac.d/ptx28
-rw-r--r--troff/troff.d/tmac.d/refer.me129
-rw-r--r--troff/troff.d/tmac.d/s.in1066
-rw-r--r--troff/troff.d/tmac.d/safe12
-rw-r--r--troff/troff.d/tmac.d/sh.me142
-rw-r--r--troff/troff.d/tmac.d/srefs169
-rw-r--r--troff/troff.d/tmac.d/taa134
-rw-r--r--troff/troff.d/tmac.d/tbl.me144
-rw-r--r--troff/troff.d/tmac.d/thesis.me52
-rw-r--r--troff/troff.d/tmac.d/tmac.gchar272
-rw-r--r--troff/troff.d/tmac.d/v555
-rw-r--r--troff/troff.d/tmac.d/vgrind406
-rw-r--r--troff/troff.d/troff.1308
-rw-r--r--troff/troff.d/troff.h67
-rw-r--r--troff/troff.d/unimap.c915
-rw-r--r--troff/troff.d/unimap.h42
345 files changed, 82743 insertions, 0 deletions
diff --git a/troff/troff.d/Makefile.mk b/troff/troff.d/Makefile.mk
new file mode 100644
index 000000000000..c5064cde9e3c
--- /dev/null
+++ b/troff/troff.d/Makefile.mk
@@ -0,0 +1,66 @@
+LIBHNJ = ../libhnj
+BST = ../../stuff/bst
+VPATH=..
+OBJ = t10.o t6.o hytab.o n1.o n2.o n3.o n4.o n5.o \
+ n7.o n8.o n9.o ni.o nii.o suftab.o makedev.o afm.o otf.o unimap.o \
+ version.o fontmap.o $(BST)/bst.o
+
+FLAGS = -DUSG $(EUC) -I. -I.. -I../../include -DMACDIR='"$(MACDIR)"' \
+ -DFNTDIR='"$(FNTDIR)"' -DTABDIR='"$(TABDIR)"' -DHYPDIR='"$(HYPDIR)"' \
+ -DSHELL='"$(SHELL)"' -DRELEASE='"$(RELEASE)"' $(DEFINES) -I$(BST)
+
+.c.o:
+ $(CC) $(CFLAGS) $(WARN) $(CPPFLAGS) $(FLAGS) -c $<
+
+all: troff ta otfdump
+
+troff: $(OBJ) $(LIBHNJ)/libhnj.a
+ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -L$(LIBHNJ) -lhnj $(LIBS) -o troff
+
+ta: draw.o ta.o
+ $(CC) $(CFLAGS) $(LDFLAGS) draw.o ta.o $(LIBS) -lm -o $@
+
+otfdump: otfdump.o otfdump_vs.o
+ $(CC) $(CFLAGS) $(LDFLAGS) otfdump.o otfdump_vs.o $(LIBS) -o $@
+
+install:
+ $(INSTALL) -c troff $(ROOT)$(BINDIR)/troff
+ $(STRIP) $(ROOT)$(BINDIR)/troff
+ $(INSTALL) -c ta $(ROOT)$(BINDIR)/ta
+ $(STRIP) $(ROOT)$(BINDIR)/ta
+ $(INSTALL) -c otfdump $(ROOT)$(BINDIR)/otf_info
+ $(STRIP) $(ROOT)$(BINDIR)/otf_info
+ $(INSTALL) -c -m 644 troff.1 $(ROOT)$(MANDIR)/man1/troff.1
+ $(INSTALL) -c -m 644 otfdump.1 $(ROOT)$(MANDIR)/man1/otf_info.1
+
+clean:
+ rm -f $(OBJ) draw.o ta.o troff ta otfdump otfdump.o otfdump_vs.o \
+ core log *~
+
+mrproper: clean
+
+draw.o: draw.c
+makedev.o: makedev.c dev.h
+t10.o: t10.c ../tdef.h ../ext.h dev.h afm.h unimap.h troff.h
+t6.o: t6.c ../tdef.h dev.h ../ext.h afm.h unimap.h troff.h
+unimap.o: unimap.h
+ta.o: ta.c dev.h
+hytab.o: ../hytab.c
+malloc.o: ../malloc.c ../mallint.h
+n1.o: ../n1.c ../tdef.h ../ext.h ./pt.h
+n2.o: ../n2.c ../tdef.h ./pt.h ../ext.h
+n3.o: ../n3.c ../tdef.h ./pt.h ../ext.h
+n4.o: ../n4.c ../tdef.h ./pt.h ../ext.h
+n5.o: ../n5.c ../tdef.h ./pt.h ../ext.h
+n7.o: ../n7.c ../tdef.h ./pt.h ../ext.h
+n8.o: ../n8.c ../tdef.h ../ext.h ./pt.h
+n9.o: ../n9.c ../tdef.h ./pt.h ../ext.h
+ni.o: ../ni.c ../tdef.h ./pt.h ../ext.h
+nii.o: ../nii.c ../tdef.h ./pt.h ../ext.h
+suftab.o: ../suftab.c
+version.o: ../version.c
+otfdump_vs.o: ../version.c
+afm.o: dev.h afm.h
+otf.o: dev.h afm.h unimap.h
+otfdump.o: afm.h afm.c otf.c otfdump.c dpost.d/getopt.c dev.h
+fontmap.o: fontmap.h
diff --git a/troff/troff.d/README b/troff/troff.d/README
new file mode 100644
index 000000000000..66c0773d0a97
--- /dev/null
+++ b/troff/troff.d/README
@@ -0,0 +1,184 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#ident "@(#)README 1.4 05/06/08 SMI"
+
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+
+The troff in this directory
+is a troff that produces machine-independent output.
+It requires a file of descriptive information about
+the particular typesetter you have in mind, and produces
+output parameterized for that device.
+
+Thus:
+ troff -Taps ...
+produces output for the Autologic APS-5.
+(This is the default.)
+
+To make this work, you need two things.
+First, you need to create a set of
+device and font descriptions in the directory
+ /usr/doctools/font/devxxx
+where "xxx" is your device name.
+Currently supported device is
+ aps Autologic APS-5 phototypesetter
+Source for this device is found in the subdirectory
+devaps of this directory.
+
+The file "DESC" contains information about the
+device itself and the character set. (See devaps/DESC.)
+
+In addition, each font needs a file describing its
+characters, width and device-driving codes;
+see R and S for typical examples.
+
+The program "makedev" will convert these text
+descriptions into a binary form that the troff can
+slurp up in a single gulp during initialization;
+these wind up in DESC.out (which includes
+default font info) and XX.out for info about font XX.
+
+The second half of the job is to write a post-processor
+that converts the more or less machine-independent troff
+output into specific codes for your favorite typesetter.
+daps.c is the driver for the APS-5;
+it will serve as a useful prototype. In particular,
+it contains a precise description of the output language.
+ ta prints ascii on ordinary terminals (crudely)
+
+One can always simply run
+ troff
+and look at the output; it is guaranteed to be ascii text
+and thus safe to edit, grep, etc.
+(Since it is ascii, it is also guaranteed to be quite voluminous.)
+
+The recommended way to create the necessary files to make troff
+able to communicate with a new output device
+is to pick the most similar device for which this software
+already exists, and modify it to suit the new device.
+
+This release contains prototype software for one
+type of device -- a phototypesetter (devaps)
+The devaps subtree contains
+profusely-commented programs and strategically placed README
+files to help guide the experienced user in making
+modifications to these files.
+
+Two other source of information for users who wish to delve
+deeply into this software are the manual pages
+troff(5), which describes the output language produced by troff,
+and font(5), which describes the format of the device
+and font description files.
+
+-----------------------------------------------------------------------------
+
+Changes since the original release:
+
+January, 1985:
+
+Added optional 3rd argument to .fp command:
+ .fp 3 xx longishname
+causes font to be called xx but data is loaded
+from longishname.out instead of xx.out.
+The intent is to deal with the proliferation of fonts.
+
+Turned NBLIST up to 2048 so can handle really big
+diversions. Tends to blow various systems.
+
+December 1984:
+
+Nroff modified to read ascii tables for various devices
+instead of the compiled C code nonsense. Only a few
+tables converted; details of language still subject to
+change.
+
+September 1984:
+
+Added Molly Wagner's code to prevent side effects
+during scanning of false branch of an if.
+
+Added test warning when one removes a macro during
+its execution (more precisely, warning when a macro
+evaluation has encountered a freed block).
+[Disabled Nov 84; it seemed to cause troubles]
+
+NS = 128; devname[] is bigger; turned off the -t
+argument (it could be a synonym for -T but that's
+probably just as risky.)
+
+July, 1984:
+
+Added TYPESETTER environment variable
+
+Added \X'...' command: ... comes out as
+ x X ...\n in proper place. (doesn't nest)
+
+In \D comands, unrecognized command letters are passed through
+untouched. This makes it possible to define things like other
+splines, filled polygons, etc.
+
+\s(dd, \s(+dd, \s(-dd size commands.
+
+Added .lf line filename to set current line number & filename
+
+Added Dan Berry's fixes to handle horizontal resolution properly.
+
+New, March 1984:
+
+Dennis Ritchie's hashed macro and number register tables;
+cached width computations, general cleanup.
+Minor work on de-linting.
+
+New comments 9/16/83
+
+This version is the current evolution of 8th Edition troff.
+The only changes of substance since the export version are
+
+ the end of a sentence is more general; things like
+ ." .!'' etc are recognized and padded
+
+ the "font too big for position n" error can no longer arise.
+ makedev has a new parameter called biggestfont that
+ ensures that all font positions are at least that big.
+ this eliminates the "font X too big for position Y" message
+
+ some minor bugs fixes have been made:
+ doesn't look for ligatures in \nf
+ doesn't put out WORDSP in -a
+
+ troff no longer produces \^ and \| on output,
+ but this hasn't been tested much since it takes
+ character set changes too.
+
diff --git a/troff/troff.d/afm.c b/troff/troff.d/afm.c
new file mode 100644
index 000000000000..f87dcefaaf58
--- /dev/null
+++ b/troff/troff.d/afm.c
@@ -0,0 +1,1201 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)afm.c 1.65 (gritter) 1/14/10
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "dev.h"
+#include "afm.h"
+
+extern char *chname;
+extern short *chtab;
+extern int nchtab;
+
+extern void errprint(const char *, ...);
+
+#if !defined (DPOST) && !defined (DUMP)
+static void addkernpair(struct afmtab *, char *_line);
+#endif
+
+/*
+ * This table maps troff special characters to PostScript names.
+ */
+const struct names {
+ char *trname;
+ char *psname;
+} names[] = {
+ { "hy", "hyphen" },
+ { "ct", "cent" },
+ { "fi", "fi" },
+ { "fi", "f_i" },
+ { "fl", "fl" },
+ { "fl", "f_l" },
+ { "ff", "ff" },
+ { "ff", "f_f" },
+ { "Fi", "ffi" },
+ { "Fi", "f_f_i" },
+ { "Fl", "ffl" },
+ { "Fl", "f_f_l" },
+ { "dg", "dagger" },
+ { "dd", "daggerdbl" },
+ { "bu", "bullet" },
+ { "de", "ring" },
+ { "em", "emdash" },
+ { "en", "endash" },
+ { "sc", "section" },
+ { "``", "quotedblleft" },
+ { "''", "quotedblright" },
+ { "12", "onehalf" },
+ { "14", "onequarter" },
+ { "34", "threequarters" },
+ { "aq", "quotesingle" },
+ { "oq", "quoteleft" },
+ { "cq", "quoteright" },
+ { 0, 0 }
+};
+
+/*
+ * Names for Symbol fonts only.
+ */
+const struct names greeknames[] = {
+ { "*A", "Alpha" },
+ { "*B", "Beta" },
+ { "*C", "Xi" },
+ { "*D", "Delta" },
+ { "*E", "Epsilon" },
+ { "*F", "Phi" },
+ { "*G", "Gamma" },
+ { "*H", "Theta" },
+ { "*I", "Iota" },
+ { "*K", "Kappa" },
+ { "*L", "Lambda" },
+ { "*M", "Mu" },
+ { "*N", "Nu" },
+ { "*O", "Omicron" },
+ { "*P", "Pi" },
+ { "*Q", "Psi" },
+ { "*R", "Rho" },
+ { "*S", "Sigma" },
+ { "*T", "Tau" },
+ { "*U", "Upsilon" },
+ { "*W", "Omega" },
+ { "*X", "Chi" },
+ { "*Y", "Eta" },
+ { "*Z", "Zeta" },
+ { "*a", "alpha" },
+ { "*b", "beta" },
+ { "*c", "xi" },
+ { "*d", "delta" },
+ { "*e", "epsilon" },
+ { "*f", "phi" },
+ { "*g", "gamma" },
+ { "*h", "theta" },
+ { "*i", "iota" },
+ { "*k", "kappa" },
+ { "*l", "lambda" },
+ { "*m", "mu" },
+ { "*n", "nu" },
+ { "*o", "omicron" },
+ { "*p", "pi" },
+ { "*q", "psi" },
+ { "*r", "rho" },
+ { "*s", "sigma" },
+ { "*t", "tau" },
+ { "*u", "upsilon" },
+ { "*w", "omega" },
+ { "*x", "chi" },
+ { "*y", "eta" },
+ { "*z", "zeta" },
+ { 0, 0 }
+};
+
+const struct names mathnames[] = {
+ { "!=", "notequal" },
+ { "**", "asteriskmath" },
+ { "+-", "plusminus" },
+ { "->", "arrowright" },
+ { "<", "less" },
+ { "<-", "arrowleft" },
+ { "<=", "lessequal" },
+ { "==", "equivalence" },
+ { ">", "greater" },
+ { ">=", "greaterequal" },
+ { "O+", "circleplus" },
+ { "Ox", "circlemultiply" },
+ { "^", "logicaland" },
+ { "al", "aleph" },
+ { "ap", "similar" },
+ { "bu", "bullet" },
+ { "ca", "intersection" },
+ { "co", "copyrightserif" },
+ { "cu", "union" },
+ { "da", "arrowdown" },
+ { "de", "degree" },
+ { "di", "divide" },
+ { "eq", "equal" },
+ { "es", "emptyset" },
+ { "fa", "universal" },
+ { "fm", "minute" },
+ { "gr", "gradient" },
+ { "ib", "reflexsubset" },
+ { "if", "infinity" },
+ { "ip", "reflexsuperset" },
+ { "is", "integral" },
+ { "mi", "minus" },
+ { "mo", "element" },
+ { "mu", "multiply" },
+ { "no", "logicalnot" },
+ { "or", "bar" },
+ { "or", "logicalor" },
+ { "pd", "partialdiff" },
+ { "pl", "plus" },
+ { "pt", "proportional" },
+ { "rg", "registerserif" },
+ { "sb", "propersubset" },
+ { "sl", "fraction" },
+ { "sp", "propersuperset" },
+ { "sr", "radical" },
+ { "te", "existential" },
+ { "tm", "trademarkserif" },
+ { "ts", "sigma1" },
+ { "ua", "arrowup" },
+ { "~~", "approxequal" },
+ { 0, 0 },
+};
+
+const struct names largenames[] = {
+ { "bv", "braceex" },
+ { "lb", "braceleftbt" },
+ { "lc", "bracketlefttp" },
+ { "lf", "bracketleftbt" },
+ { "lk", "braceleftmid" },
+ { "lt", "bracelefttp" },
+ { "rb", "bracerightbt" },
+ { "rc", "bracketrighttp" },
+ { "rf", "bracketrightbt" },
+ { "rk", "bracerightmid" },
+ { "rn", "radicalex" },
+ { "rt", "bracerighttp" },
+ { 0, 0 }
+};
+
+const struct names punctnames[] = {
+ { "or", "bar" },
+ { "\\-","endash" },
+ { "aa","acute" },
+ { "ga","grave" },
+ { "rs","backslash" },
+ { "dq","quotedbl" },
+ { 0, 0 }
+};
+
+/*
+ * These names are only used with the S font.
+ */
+const struct names Snames[] = {
+ { "br", "parenleftex" },
+ { "ul", "underscore" },
+ { "vr", "bracketleftex" },
+ { 0, 0 }
+};
+
+/*
+ * These names are only used with the S1 font.
+ */
+const struct names S1names[] = {
+ { "ru", "underscore" },
+ { 0, 0 }
+};
+
+/*
+ * Figures from charlib.
+ */
+#define NCHARLIB 16
+static const struct charlib {
+ const char *name;
+ int width;
+ int kern;
+ int code;
+ int symbol;
+ enum {
+ NEEDS_F = 01,
+ NEEDS_I = 02,
+ NEEDS_L = 04
+ } needs;
+} charlib[] = {
+ { "bx", 500, 2, 1, 0, 0 },
+ { "ci", 750, 0, 1, 0, 0 },
+ { "sq", 500, 2, 1, 0, 0 },
+ { "ff", 600, 2, 1, 0, 1 }, /* widths of the ligatures */
+ { "Fi", 840, 2, 1, 0, 3 }, /* are likely wrong, but */
+ { "Fl", 840, 2, 1, 0, 5 }, /* they are normally not used */
+ { "~=", 550, 0, 1, 1, 0 },
+ { "L1", 1100, 1, 2, 1, 0 },
+ { "LA", 1100, 1, 2, 1, 0 },
+ { "LV", 1100, 3, 2, 1, 0 },
+ { "LH", 2100, 1, 2, 1, 0 },
+ { "Lb", 2100, 1, 2, 1, 0 },
+ { "lh", 1000, 0, 2, 1, 0 },
+ { "rh", 1000, 0, 2, 1, 0 },
+ { "Sl", 500, 2, 1, 1, 0 },
+ { "ob", 380, 0, 1, 1, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+/*
+ * The values in this table determine if a character that is found on an
+ * ASCII position in a PostScript font actually is that ASCII character.
+ * If not, the position in fitab remains empty, and the fallback sequence
+ * is used to find it in another font.
+ */
+static const struct asciimap {
+ int code;
+ const char *psc;
+} asciimap[] = {
+ { 0x0020, "space" },
+ { 0x0021, "exclam" },
+ { 0x0024, "dollar" },
+ { 0x0024, "dollaralt" }, /* FournierMT-RegularAlt */
+ { 0x0025, "percent" },
+ { 0x0026, "ampersand" },
+ { 0x0026, "ampersandalt" }, /* AGaramondAlt-Italic */
+ { 0x0027, "quoteright" },
+ { 0x0028, "parenleft" },
+ { 0x0029, "parenright" },
+ { 0x002A, "asterisk" },
+ { 0x002B, "plus" },
+ { 0x002C, "comma" },
+ { 0x002D, "hyphen" },
+ { 0x002E, "period" },
+ { 0x002F, "slash" },
+ { 0x0030, "zero" },
+ { 0x0030, "zerooldstyle" },
+ { 0x0030, "zeroalt" }, /* BulmerMT-RegularAlt */
+ { 0x0031, "one" },
+ { 0x0031, "oneoldstyle" },
+ { 0x0031, "onefitted" },
+ { 0x0031, "onealtfitted" }, /* BulmerMT-ItalicAlt */
+ { 0x0032, "two" },
+ { 0x0032, "twooldstyle" },
+ { 0x0032, "twoalt" }, /* BulmerMT-RegularAlt */
+ { 0x0033, "three" },
+ { 0x0033, "threeoldstyle" },
+ { 0x0033, "threealt" }, /* BulmerMT-RegularAlt */
+ { 0x0034, "four" },
+ { 0x0034, "fouroldstyle" },
+ { 0x0034, "fouralt" }, /* BulmerMT-RegularAlt */
+ { 0x0035, "five" },
+ { 0x0035, "fiveoldstyle" },
+ { 0x0035, "fivealt" }, /* BulmerMT-RegularAlt */
+ { 0x0036, "six" },
+ { 0x0036, "sixoldstyle" },
+ { 0x0036, "sixalt" }, /* BulmerMT-RegularAlt */
+ { 0x0037, "seven" },
+ { 0x0037, "sevenoldstyle" },
+ { 0x0037, "sevenalt" }, /* BulmerMT-RegularAlt */
+ { 0x0038, "eight" },
+ { 0x0038, "eightoldstyle" },
+ { 0x0038, "eightalt" }, /* BulmerMT-RegularAlt */
+ { 0x0039, "nine" },
+ { 0x0039, "nineoldstyle" },
+ { 0x0039, "ninealt" }, /* BulmerMT-RegularAlt */
+ { 0x003A, "colon" },
+ { 0x003B, "semicolon" },
+ { 0x003D, "equal" },
+ { 0x003F, "question" },
+ { 0x0041, "A" },
+ { 0x0041, "Aswash" }, /* AGaramondAlt-Italic */
+ { 0x0042, "B" },
+ { 0x0042, "Bswash" }, /* AGaramondAlt-Italic */
+ { 0x0043, "C" },
+ { 0x0043, "Cswash" }, /* AGaramondAlt-Italic */
+ { 0x0044, "D" },
+ { 0x0044, "Dswash" }, /* AGaramondAlt-Italic */
+ { 0x0045, "E" },
+ { 0x0045, "Eswash" }, /* AGaramondAlt-Italic */
+ { 0x0046, "F" },
+ { 0x0046, "Fswash" }, /* AGaramondAlt-Italic */
+ { 0x0047, "G" },
+ { 0x0047, "Gswash" }, /* AGaramondAlt-Italic */
+ { 0x0048, "H" },
+ { 0x0048, "Hswash" }, /* AGaramondAlt-Italic */
+ { 0x0049, "I" },
+ { 0x0049, "Iswash" }, /* AGaramondAlt-Italic */
+ { 0x004A, "J" },
+ { 0x004A, "Jalt" }, /* FournierMT-RegularAlt */
+ { 0x004A, "Jalttwo" }, /* BulmerMT-ItalicAlt */
+ { 0x004A, "Jswash" }, /* AGaramondAlt-Italic */
+ { 0x004A, "JTallCapalt" }, /* FournierMT-RegularAlt */
+ { 0x004B, "K" },
+ { 0x004B, "Kalt" }, /* BulmerMT-ItalicAlt */
+ { 0x004B, "Kswash" }, /* AGaramondAlt-Italic */
+ { 0x004C, "L" },
+ { 0x004C, "Lswash" }, /* AGaramondAlt-Italic */
+ { 0x004D, "M" },
+ { 0x004D, "Mswash" }, /* AGaramondAlt-Italic */
+ { 0x004E, "N" },
+ { 0x004E, "Nalt" }, /* BulmerMT-ItalicAlt */
+ { 0x004E, "Nswash" }, /* AGaramondAlt-Italic */
+ { 0x004F, "O" },
+ { 0x004F, "Oalt" }, /* BulmerMT-ItalicAlt */
+ { 0x004F, "Oswash" }, /* AGaramondAlt-Italic */
+ { 0x0050, "P" },
+ { 0x0050, "Pswash" }, /* AGaramondAlt-Italic */
+ { 0x0051, "Q" },
+ { 0x0051, "Qalt" }, /* FournierMT-RegularAlt */
+ { 0x0051, "Qalttitling" }, /* AGaramondAlt-Regular */
+ { 0x0051, "Qswash" }, /* AGaramondAlt-Italic */
+ { 0x0051, "QTallCapalt" }, /* FournierMT-RegularAlt */
+ { 0x0052, "R" },
+ { 0x0052, "Ralternate" }, /* Bembo-Alt */
+ { 0x0052, "Rswash" }, /* AGaramondAlt-Italic */
+ { 0x0053, "S" },
+ { 0x0053, "Sswash" }, /* AGaramondAlt-Italic */
+ { 0x0054, "T" },
+ { 0x0054, "Talt" }, /* BulmerMT-ItalicAlt */
+ { 0x0054, "Tswash" }, /* AGaramondAlt-Italic */
+ { 0x0055, "U" },
+ { 0x0055, "Uswash" }, /* AGaramondAlt-Italic */
+ { 0x0056, "V" },
+ { 0x0056, "Vswash" }, /* AGaramondAlt-Italic */
+ { 0x0057, "W" },
+ { 0x0057, "Wswash" }, /* AGaramondAlt-Italic */
+ { 0x0058, "X" },
+ { 0x0058, "Xswash" }, /* AGaramondAlt-Italic */
+ { 0x0059, "Y" },
+ { 0x0059, "Yalt" }, /* BulmerMT-ItalicAlt */
+ { 0x0059, "Yswash" }, /* AGaramondAlt-Italic */
+ { 0x005A, "Z" },
+ { 0x005A, "Zswash" }, /* AGaramondAlt-Italic */
+ { 0x005B, "bracketleft" },
+ { 0x005D, "bracketright" },
+ { 0x005F, "underscore" },
+ { 0x0060, "quoteleft" },
+ { 0x0060, "quotealtleft" }, /* BulmerMT-RegularAlt */
+ { 0x0061, "a" },
+ { 0x0061, "Asmall" },
+ { 0x0061, "aswash" }, /* AGaramondAlt-Regular */
+ { 0x0062, "b" },
+ { 0x0062, "Bsmall" },
+ { 0x0063, "c" },
+ { 0x0063, "Csmall" },
+ { 0x0064, "d" },
+ { 0x0064, "Dsmall" },
+ { 0x0065, "e" },
+ { 0x0065, "Esmall" },
+ { 0x0065, "eswash" }, /* AGaramondAlt-Regular */
+ { 0x0066, "f" },
+ { 0x0066, "Fsmall" },
+ { 0x0067, "g" },
+ { 0x0067, "Gsmall" },
+ { 0x0068, "h" },
+ { 0x0068, "Hsmall" },
+ { 0x0069, "i" },
+ { 0x0069, "Ismall" },
+ { 0x006A, "j" },
+ { 0x006A, "Jsmall" },
+ { 0x006A, "Jsmallalt" }, /* FournierMT-RegularAlt */
+ { 0x006B, "k" },
+ { 0x006B, "Ksmall" },
+ { 0x006C, "l" },
+ { 0x006C, "Lsmall" },
+ { 0x006D, "m" },
+ { 0x006D, "Msmall" },
+ { 0x006E, "n" },
+ { 0x006E, "Nsmall" },
+ { 0x006E, "nswash" }, /* AGaramondAlt-Regular */
+ { 0x006F, "o" },
+ { 0x006F, "Osmall" },
+ { 0x0070, "p" },
+ { 0x0070, "Psmall" },
+ { 0x0071, "q" },
+ { 0x0071, "Qsmall" },
+ { 0x0072, "r" },
+ { 0x0072, "Rsmall" },
+ { 0x0072, "rswash" }, /* AGaramondAlt-Regular */
+ { 0x0073, "s" },
+ { 0x0073, "Ssmall" },
+ { 0x0074, "t" },
+ { 0x0074, "Tsmall" },
+ { 0x0074, "tswash" }, /* AGaramondAlt-Regular */
+ { 0x0074, "tswashalt" }, /* AGaramondAlt-Regular */
+ { 0x0075, "u" },
+ { 0x0075, "Usmall" },
+ { 0x0076, "v" },
+ { 0x0076, "Vsmall" },
+ { 0x0076, "vswash" }, /* AGaramondAlt-Italic */
+ { 0x0077, "w" },
+ { 0x0077, "Wsmall" },
+ { 0x0077, "walt" }, /* FournierMT-RegularAlt */
+ { 0x0078, "x" },
+ { 0x0078, "Xsmall" },
+ { 0x0079, "y" },
+ { 0x0079, "Ysmall" },
+ { 0x007A, "z" },
+ { 0x007A, "Zsmall" },
+ { 0x007A, "zalt" }, /* FournierMT-ItalicAlt */
+ { 0x007A, "zswash" }, /* AGaramondAlt-Regular */
+ { 0x007B, "braceleft" },
+ { 0x007C, "bar" },
+ { 0x007D, "braceright" },
+ { 0, 0 }
+};
+
+/*
+ * ASCII characters that are always taken from the S (math) font.
+ */
+static const struct asciimap mathascii[] = {
+ { 0x002D, "minus" },
+ { 0x007E, "similar" },
+ { 0, 0 }
+};
+
+/*
+ * ASCII characters that are always taken from the S1 (punct) font.
+ */
+static const struct asciimap punctascii[] = {
+ { 0x0022, "quotedbl" },
+ { 0x0023, "numbersign" },
+ { 0x003C, "less" },
+ { 0x003E, "greater" },
+ { 0x0040, "at" },
+ { 0x005C, "backslash" },
+ { 0x005E, "circumflex" },
+ { 0x007E, "tilde" },
+ { 0, NULL }
+};
+
+int
+nextprime(int n)
+{
+ const int primes[] = {
+ 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521,
+ 131071, 262139, 524287, 1048573, 2097143, 4194301,
+ 8388593, 16777213, 33554393, 67108859, 134217689,
+ 268435399, 536870909, 1073741789, 2147483647
+ };
+ int mprime = 7;
+ int i;
+
+ for (i = 0; i < sizeof primes / sizeof *primes; i++)
+ if ((mprime = primes[i]) >= (n < 65536 ? n*4 :
+ n < 262144 ? n*2 : n))
+ break;
+ if (i == sizeof primes / sizeof *primes)
+ mprime = n; /* not so prime, but better than failure */
+ return mprime;
+}
+
+unsigned
+pjw(const char *cp)
+{
+ unsigned h = 0, g;
+
+ cp--;
+ while (*++cp) {
+ h = (h << 4 & 0xffffffff) + (*cp&0377);
+ if ((g = h & 0xf0000000) != 0) {
+ h = h ^ g >> 24;
+ h = h ^ g;
+ }
+ }
+ return h;
+}
+
+struct namecache *
+afmnamelook(struct afmtab *a, const char *name)
+{
+ struct namecache *np;
+ unsigned h, c, n = 0;
+
+ h = pjw(name) % a->nameprime;
+ np = &a->namecache[c = h];
+ while (np->afpos != 0) {
+ if (a->nametab[np->afpos] == 0 ||
+ strcmp(a->nametab[np->afpos], name) == 0)
+ break;
+ h = (n + 1) / 2;
+ h *= h;
+ if (n & 1)
+ c -= h;
+ else
+ c += h;
+ n++;
+ while (c >= a->nameprime)
+ c -= a->nameprime;
+ np = &a->namecache[c];
+ }
+ return np;
+}
+
+static int
+mapname1(const char *psname, const struct names *np)
+{
+ int i, j;
+
+ for (i = 0; np[i].trname; i++)
+ if (strcmp(np[i].psname, psname) == 0)
+ break;
+ if (np[i].trname)
+ for (j = 0; j < nchtab; j++)
+ if (strcmp(np[i].trname, &chname[chtab[j]]) == 0)
+ return j + 128;
+ return 0;
+}
+
+int
+afmmapname(const char *psname, enum spec s)
+{
+ int k;
+
+ if (s & SPEC_S && (k = mapname1(psname, Snames)) > 0)
+ return k;
+ if (s & SPEC_S1 && (k = mapname1(psname, S1names)) > 0)
+ return k;
+ if (s & (SPEC_MATH|SPEC_S) && (k = mapname1(psname, mathnames)) > 0)
+ return k;
+ if (s & (SPEC_GREEK|SPEC_S) && (k = mapname1(psname, greeknames)) > 0)
+ return k;
+ if (s & (SPEC_LARGE|SPEC_S) && (k = mapname1(psname, largenames)) > 0)
+ return k;
+ if (s & (SPEC_PUNCT|SPEC_S1) && (k = mapname1(psname, punctnames)) > 0)
+ return k;
+ return mapname1(psname, names);
+}
+
+/*
+ * After all characters have been read, construct a font-specific
+ * encoding for the rest. Also move the name table to permanent space.
+ */
+void
+afmremap(struct afmtab *a)
+{
+ int i, j = 128 - 32 + nchtab;
+ char *space, *tp;
+ struct namecache *np;
+
+ for (i = 1; i < a->nchars; i++) {
+ if (a->codetab[i] == NOCODE && a->nametab[i] != NULL) {
+#if defined (DPOST) || defined (DUMP)
+ while (a->fitab[j] != 0)
+ j++;
+#else /* TROFF */
+ extern int ps2cc(const char *);
+ j = ps2cc(a->nametab[i]) + 128 - 32 + nchtab;
+#endif /* TROFF */
+ a->fitab[j] = i;
+ np = afmnamelook(a, a->nametab[i]);
+ np->afpos = i;
+ np->fival[0] = j;
+ if (np->gid != 0 && a->gid2tr)
+ a->gid2tr[np->gid].ch1 = j + 32 + nchtab + 128;
+ if (strcmp(a->nametab[i], "space") == 0) {
+ np->fival[1] = 0;
+ if (np->gid != 0 && a->gid2tr)
+ a->gid2tr[np->gid].ch2 = 32;
+ }
+ }
+ }
+ space = malloc(a->nspace);
+ for (i = 0; i < a->nchars; i++) {
+ if (a->nametab[i]) {
+ tp = a->nametab[i];
+ a->nametab[i] = space;
+ while ((*space++ = *tp++));
+ }
+ }
+}
+
+#ifndef DUMP
+static int
+asciiequiv(int code, const char *psc, enum spec s)
+{
+ int i;
+
+ if (psc != NULL) {
+ for (i = 0; asciimap[i].psc; i++)
+ if (strcmp(asciimap[i].psc, psc) == 0)
+ return asciimap[i].code;
+ if (s & (SPEC_MATH|SPEC_S)) {
+ for (i = 0; mathascii[i].psc; i++)
+ if (strcmp(mathascii[i].psc, psc) == 0)
+ return mathascii[i].code;
+ }
+ if (s & (SPEC_PUNCT|SPEC_S1)) {
+ for (i = 0; punctascii[i].psc; i++)
+ if (strcmp(punctascii[i].psc, psc) == 0)
+ return punctascii[i].code;
+ }
+ }
+ return 0;
+}
+
+static char *
+thisword(const char *text, const char *wrd)
+{
+ while (*text == *wrd)
+ text++, wrd++;
+ if (*wrd != 0)
+ return 0;
+ if (*text == 0 || *text == ' ' || *text == '\t' || *text == '\n' ||
+ *text == '\r') {
+ while (*text != 0 && (*text == ' ' || *text == '\t'))
+ text++;
+ return (char *)text;
+ }
+ return NULL;
+}
+#endif /* !DUMP */
+
+int
+unitconv(int i)
+{
+ if (unitsPerEm * 72 != dev.unitwidth * dev.res)
+ i = i * dev.unitwidth * dev.res / 72 / unitsPerEm;
+ return i;
+}
+
+#ifndef DUMP
+void
+afmaddchar(struct afmtab *a, int C, int tp, int cl, int WX, int B[4], char *N,
+ enum spec s, int gid)
+{
+ struct namecache *np = NULL;
+
+ if (N != NULL) {
+ np = afmnamelook(a, N);
+ np->afpos = a->nchars;
+ np->gid = gid;
+ if (a->isFixedPitch && strcmp(N, "space") == 0)
+ a->fontab[0] = _unitconv(WX);
+ }
+ a->fontab[a->nchars] = _unitconv(WX);
+ if (B) {
+ a->bbtab[a->nchars] = malloc(4 * sizeof **a->bbtab);
+ a->bbtab[a->nchars][0] = _unitconv(B[0]);
+ a->bbtab[a->nchars][1] = _unitconv(B[1]);
+ a->bbtab[a->nchars][2] = _unitconv(B[2]);
+ a->bbtab[a->nchars][3] = _unitconv(B[3]);
+ /*
+ * Crude heuristics mainly based on observations with the existing
+ * fonts for -Tpost and on tests with eqn.
+ */
+ if (B[1] <= -10)
+ a->kerntab[a->nchars] |= 1;
+ if (B[3] > (a->xheight + a->capheight) / 2)
+ a->kerntab[a->nchars] |= 2;
+ }
+ /*
+ * Only map a character directly if it maps to an ASCII
+ * equivalent or to a troff special character.
+ */
+ C = asciiequiv(C, N, s);
+ if (cl)
+ a->codetab[a->nchars] = cl;
+ else if (tp)
+ a->codetab[a->nchars] = tp;
+ else if (C > 32 && C < 127 && a->fitab[C - 32] == 0)
+ a->codetab[a->nchars] = C;
+ else
+ a->codetab[a->nchars] = NOCODE;
+ if (C > 32 && C < 127 && a->fitab[C - 32] == 0) {
+ a->fitab[C - 32] = a->nchars;
+ if (gid && a->gid2tr)
+ a->gid2tr[gid].ch1 = C;
+ if (np)
+ np->fival[0] = C - 32;
+ } else if (C == 32 && np)
+ np->fival[0] = 0;
+ if (tp) {
+ a->fitab[tp - 32] = a->nchars;
+ if (gid && a->gid2tr)
+ a->gid2tr[gid].ch2 = tp;
+ if (np)
+ np->fival[1] = tp - 32;
+ }
+ a->nametab[a->nchars] = N;
+ a->nchars++;
+}
+
+/*
+ * Add charlib figues.
+ */
+static void
+addcharlib(struct afmtab *a, int symbol)
+{
+ int i, j;
+ int B[4] = { 0, 0, 0, 0 };
+
+ for (j = 0; j < nchtab; j++)
+ for (i = 0; charlib[i].name; i++) {
+ if (charlib[i].symbol && !symbol)
+ continue;
+ if (charlib[i].needs & NEEDS_F && a->fitab['f'-32] == 0)
+ continue;
+ if (charlib[i].needs & NEEDS_I && a->fitab['i'-32] == 0)
+ continue;
+ if (charlib[i].needs & NEEDS_L && a->fitab['l'-32] == 0)
+ continue;
+ if (strcmp(charlib[i].name, &chname[chtab[j]]) == 0) {
+ B[1] = charlib[i].kern & 1 ? -11 : 0;
+ B[3] = charlib[i].kern & 2 ?
+ a->capheight + 1 : 0;
+ afmaddchar(a, NOCODE, j+128, charlib[i].code,
+ charlib[i].width * unitsPerEm / 1024,
+ B, NULL, SPEC_NONE, 0);
+ }
+ }
+}
+
+static void
+addmetrics(struct afmtab *a, char *_line, enum spec s)
+{
+ char *lp = _line, c, *xp;
+ int C = NOCODE, WX = 0, tp;
+ char *N = NULL;
+ int B[4] = { -1, -1, -1, -1 };
+
+ while (*lp && *lp != '\n' && *lp != '\r') {
+ switch (*lp) {
+ case 'C':
+ C = strtol(&lp[1], NULL, 10);
+ break;
+ case 'W':
+ if (lp[1] == 'X')
+ WX = strtol(&lp[2], NULL, 10);
+ break;
+ case 'N':
+ for (N = &lp[1]; *N == ' ' || *N == '\t'; N++);
+ for (lp = N; *lp && *lp != '\n' && *lp != '\r' &&
+ *lp != ' ' && *lp != '\t' &&
+ *lp != ';'; lp++);
+ c = *lp;
+ *lp++ = 0;
+ a->nspace += lp - N;
+ if (c == ';')
+ continue;
+ break;
+ case 'B':
+ xp = &lp[1];
+ B[0] = strtol(xp, &xp, 10);
+ B[1] = strtol(xp, &xp, 10);
+ B[2] = strtol(xp, &xp, 10);
+ B[3] = strtol(xp, &xp, 10);
+ break;
+ case 'L':
+ if (C == 'f') {
+ xp = &lp[1];
+ while (*xp == ' ' || *xp == '\t')
+ xp++;
+ switch (*xp) {
+ case 'i':
+ a->Font.ligfont |= LFI;
+ break;
+ case 'l':
+ a->Font.ligfont |= LFL;
+ break;
+ }
+ }
+ break;
+ default:
+ lp++;
+ }
+ while (*lp && *lp != '\n' && *lp != '\r' && *lp != ';')
+ lp++;
+ if (*lp == ';') {
+ while (*lp && *lp != '\n' && *lp != '\r' &&
+ (*lp == ' ' || *lp == '\t' ||
+ *lp == ';'))
+ lp++;
+ }
+ }
+ if (N == NULL)
+ return;
+ tp = afmmapname(N, s);
+ afmaddchar(a, C, tp, 0, WX, B, N, s, 0);
+}
+
+void
+afmalloc(struct afmtab *a, int n)
+{
+ int i;
+
+#if defined (DPOST) || defined (DUMP)
+ a->fichars = n+NCHARLIB+1 + 128 - 32 + nchtab;
+#else /* TROFF */
+ extern int psmaxcode;
+ a->fichars = n+NCHARLIB+1 + 128 - 32 + nchtab + psmaxcode+1;
+#endif /* TROFF */
+ a->fitab = calloc(a->fichars, sizeof *a->fitab);
+ a->fontab = malloc((n+NCHARLIB+1)*sizeof *a->fontab);
+ a->fontab[0] = dev.res * dev.unitwidth / 72 / 3;
+ a->bbtab = calloc(n+NCHARLIB+1, sizeof *a->bbtab);
+ a->kerntab = calloc(n+NCHARLIB+1, sizeof *a->kerntab);
+ a->codetab = malloc((n+NCHARLIB+1)*sizeof *a->codetab);
+ a->codetab[0] = 0;
+ for (i = 1; i < n+NCHARLIB+1; i++)
+ a->codetab[i] = NOCODE;
+ a->nametab = malloc((n+NCHARLIB+1)*sizeof *a->nametab);
+ a->nametab[0] = 0;
+ a->nchars = 1;
+ addcharlib(a, (a->base[0]=='S' && a->base[1]==0) || a->spec&SPEC_S);
+ a->nameprime = nextprime(n+NCHARLIB+1);
+ a->namecache = calloc(a->nameprime, sizeof *a->namecache);
+ for (i = 0; i < a->nameprime; i++) {
+ a->namecache[i].fival[0] = NOCODE;
+ a->namecache[i].fival[1] = NOCODE;
+ }
+}
+
+int
+afmget(struct afmtab *a, char *contents, size_t size)
+{
+ enum {
+ NONE,
+ FONTMETRICS,
+ CHARMETRICS,
+ KERNDATA,
+ KERNPAIRS
+ } state = NONE;
+ char *cp, *th, *tp;
+ int n = 0;
+ enum spec s;
+ size_t l;
+
+ if ((cp = strrchr(a->file, '/')) == NULL)
+ cp = a->file;
+ else
+ cp++;
+ l = strlen(cp) + 1;
+ a->base = malloc(l);
+ n_strcpy(a->base, cp, l);
+ if ((cp = strrchr(a->base, '.')) != NULL)
+ *cp = '\0';
+ if (dev.allpunct)
+ a->spec |= SPEC_PUNCT;
+ if (a->base[0]=='S' && a->base[1]==0)
+ a->spec |= SPEC_S;
+ if (a->base[0]=='S' && a->base[1]=='1' && a->base[2]==0)
+ a->spec |= SPEC_S1;
+ s = a->spec;
+ a->xheight = 500;
+ a->capheight = 700;
+ unitsPerEm = 1000;
+ if (memcmp(contents, "OTTO", 4) == 0 ||
+ memcmp(contents, "\0\1\0\0", 4) == 0 ||
+ memcmp(contents, "true", 4) == 0)
+ return otfget(a, contents, size);
+ a->lineno = 1;
+ for (cp = contents; cp < &contents[size]; a->lineno++, cp++) {
+ while (*cp == ' ' || *cp == '\t' || *cp == '\r')
+ cp++;
+ if (*cp == '\n')
+ continue;
+ if (thisword(cp, "Comment"))
+ /*EMPTY*/;
+ else if (state == NONE && thisword(cp, "StartFontMetrics"))
+ state = FONTMETRICS;
+ else if (state == FONTMETRICS && thisword(cp, "EndFontMetrics"))
+ state = NONE;
+ else if (state == FONTMETRICS &&
+ (th = thisword(cp, "FontName")) != NULL) {
+ for (tp = th; *tp && *tp != ' ' && *tp != '\t' &&
+ *tp != '\n' && *tp != '\r'; tp++);
+ a->fontname = malloc(tp - th + 1);
+ memcpy(a->fontname, th, tp - th);
+ a->fontname[tp - th] = 0;
+ } else if (state == FONTMETRICS &&
+ (th = thisword(cp, "IsFixedPitch")) != NULL) {
+ a->isFixedPitch = strncmp(th, "true", 4) == 0;
+ } else if (state == FONTMETRICS &&
+ (th = thisword(cp, "XHeight")) != NULL) {
+ a->xheight = strtol(th, NULL, 10);
+ } else if (state == FONTMETRICS &&
+ (th = thisword(cp, "CapHeight")) != NULL) {
+ a->capheight = strtol(th, NULL, 10);
+ } else if (state == FONTMETRICS &&
+ (th = thisword(cp, "Ascender")) != NULL) {
+ a->ascender = strtol(th, NULL, 10);
+ } else if (state == FONTMETRICS &&
+ (th = thisword(cp, "Descender")) != NULL) {
+ a->descender = strtol(th, NULL, 10);
+ } else if (state == FONTMETRICS &&
+ (th = thisword(cp, "StartCharMetrics")) != 0) {
+ n = strtol(th, NULL, 10);
+ state = CHARMETRICS;
+ afmalloc(a, n);
+ } else if (state == CHARMETRICS &&
+ thisword(cp, "EndCharMetrics")) {
+ state = FONTMETRICS;
+ afmremap(a);
+ } else if (state == CHARMETRICS && n-- > 0) {
+ addmetrics(a, cp, s);
+#ifndef DPOST
+ } else if (state == FONTMETRICS &&
+ thisword(cp, "StartKernData") != 0) {
+ state = KERNDATA;
+ } else if (state == KERNDATA &&
+ (th = thisword(cp, "StartKernPairs")) != 0) {
+ n = strtol(th, NULL, 10);
+ state = KERNPAIRS;
+ } else if (state == KERNPAIRS &&
+ thisword(cp, "EndKernPairs")) {
+ state = KERNDATA;
+ } else if (state == KERNPAIRS && n-- > 0) {
+ addkernpair(a, cp);
+ } else if (state == KERNDATA &&
+ thisword(cp, "EndKernData")) {
+ state = FONTMETRICS;
+#endif /* !DPOST */
+ }
+ while (cp < &contents[size] && *cp != '\n')
+ cp++;
+ }
+ if (a->fontname == NULL) {
+ errprint("Missing \"FontName\" in %s", a->path);
+ return -1;
+ }
+ a->Font.nwfont = a->nchars > 255 ? 255 : a->nchars;
+ return 0;
+}
+
+/*
+ * This is for legacy font support. It exists at this place because both
+ * troff and dpost need it in combination with AFM support.
+ */
+void
+makefont(int nf, char *devfontab, char *devkerntab, char *devcodetab,
+ char *devfitab, int nw)
+{
+ int i;
+
+ free(fontab[nf]);
+ free(kerntab[nf]);
+ free(codetab[nf]);
+ free(fitab[nf]);
+ fontab[nf] = calloc(nw, sizeof *fontab);
+ kerntab[nf] = calloc(nw, sizeof *kerntab);
+ codetab[nf] = calloc(nw, sizeof *codetab);
+ fitab[nf] = calloc(NCHARS ? NCHARS : 128 - 32 + nchtab, sizeof *fitab);
+ if (devfontab) for (i = 0; i < nw; i++)
+ fontab[nf][i] = devfontab[i]&0377;
+ if (devkerntab) for (i = 0; i < nw; i++)
+ kerntab[nf][i] = devkerntab[i]&0377;
+ if (devcodetab) for (i = 0; i < nw; i++)
+ codetab[nf][i] = devcodetab[i]&0377;
+ if (devfitab) for (i = 0; i < 128 - 32 + nchtab; i++)
+ fitab[nf][i] = devfitab[i]&0377;
+ fontbase[nf]->spacewidth = fontab[nf][0];
+ fontbase[nf]->cspacewidth = -1;
+}
+
+#ifndef DPOST
+/*
+ * For short to medium-sized documents, the run time is dominated by
+ * the time required to read kerning pairs for fonts with many pairs.
+ * Kerning pairs are thus simply dumped in the order they occur at
+ * this point. Later when a kerning pair is actually looked up, the
+ * structures accessed are sorted (eliding duplicates), leading to
+ * better performance with large documents.
+ */
+void
+afmaddkernpair(struct afmtab *a, int ch1, int ch2, int k)
+{
+ struct kernpairs *kp;
+
+ if (k == 0)
+ return;
+ if (a->kernpairs == NULL)
+ a->kernpairs = calloc(a->fichars, sizeof *a->kernpairs);
+ kp = &a->kernpairs[ch1];
+ while (kp->cnt == NKERNPAIRS) {
+ if (kp->next == NULL)
+ kp->next = calloc(1, sizeof *kp->next);
+ kp = kp->next;
+ }
+ kp->ch2[kp->cnt] = ch2;
+ kp->k[kp->cnt] = k;
+ kp->cnt++;
+}
+
+static void
+addkernpair(struct afmtab *a, char *_line)
+{
+ struct namecache *np1, *np2;
+ char *lp = _line, c, *cp;
+ int n, i, j;
+
+ if (lp[0] == 'K' && lp[1] == 'P') {
+ lp += 2;
+ if (*lp == 'X')
+ lp++;
+ while ((*lp && *lp == ' ') || *lp == '\t')
+ lp++;
+ cp = lp;
+ while (*lp && *lp != '\n' && *lp != '\r' &&
+ *lp != ' ' && *lp != '\t')
+ lp++;
+ if ((c = *lp) == 0)
+ return;
+ *lp = 0;
+ np1 = afmnamelook(a, cp);
+ *lp = c;
+ while ((*lp && *lp == ' ') || *lp == '\t')
+ lp++;
+ cp = lp;
+ while (*lp && *lp != '\n' && *lp != '\r' &&
+ *lp != ' ' && *lp != '\t')
+ lp++;
+ if ((c = *lp) == 0)
+ return;
+ *lp = 0;
+ np2 = afmnamelook(a, cp);
+ *lp = c;
+ n = _unitconv(strtol(&lp[1], NULL, 10));
+ for (i = 0; i < 2; i++)
+ if (np1->fival[i] != NOCODE)
+ for (j = 0; j < 2; j++)
+ if (np2->fival[j] != NOCODE)
+ afmaddkernpair(a,
+ np1->fival[i],
+ np2->fival[j],
+ n);
+ }
+}
+
+static void
+sortkernpairs(struct kernpairs *kp)
+{
+ int i, j, s, t;
+ do {
+ s = 0;
+ for (i = 0; i < kp->cnt-1; i++)
+ if (kp->ch2[i] > kp->ch2[i+1]) {
+ t = kp->ch2[i];
+ kp->ch2[i] = kp->ch2[i+1];
+ kp->ch2[i+1] = t;
+ t = kp->k[i];
+ kp->k[i] = kp->k[i+1];
+ kp->k[i+1] = t;
+ s = 1;
+ }
+ } while (s);
+ for (j = 0; j < kp->cnt-1; j++)
+ if (kp->ch2[j] == kp->ch2[j+1]) {
+ for (i = j+1; i < kp->cnt-1; i++) {
+ kp->ch2[i] = kp->ch2[i+1];
+ kp->k[i] = kp->k[i+1];
+ }
+ kp->cnt--;
+ j--;
+ }
+ kp->sorted = 1;
+}
+
+int
+afmgetkern(struct afmtab *a, int ch1, int ch2)
+{
+ struct kernpairs *kp;
+ int l, m, r;
+
+ if (a->kernpairs) {
+ kp = &a->kernpairs[ch1];
+ do {
+ if (kp->sorted == 0)
+ sortkernpairs(kp);
+ r = kp->cnt - 1;
+ if (ch2 >= kp->ch2[0] && r >= 0 && ch2 <= kp->ch2[r]) {
+ l = 0;
+ do {
+ m = (l+r) / 2;
+ if (ch2 < kp->ch2[m])
+ r = m-1;
+ else
+ l = m+1;
+ } while (ch2 != kp->ch2[m] && l <= r);
+ if (kp->ch2[m] == ch2)
+ return kp->k[m];
+ }
+ } while ((kp = kp->next) != NULL);
+ }
+ return 0;
+}
+#endif /* !DPOST */
+
+char *
+afmencodepath(const char *cp)
+{
+ const char hex[] = "0123456789ABCDEF";
+ char *enc, *ep;
+
+ ep = enc = malloc(3 * strlen(cp) + 1);
+ while (*cp) {
+ if (*cp&0200 || *cp <= 040 || *cp == 0177) {
+ *ep++ = '%';
+ *ep++ = hex[(*cp&0360) >> 4];
+ *ep++ = hex[*cp++&017];
+ } else
+ *ep++ = *cp++;
+ }
+ *ep = 0;
+ return enc;
+}
+
+static int
+unhex(int c)
+{
+ if (c >= 'A' && c <= 'F')
+ return c - 'A';
+ if (c >= 'a' && c <= 'f')
+ return c - 'a';
+ return c - '0';
+}
+
+static int
+xdigit(int c)
+{
+ return (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') ||
+ (c >= '0' && c <= '9');
+}
+
+char *
+afmdecodepath(const char *cp)
+{
+ char *dec, *dp;
+
+ dec = dp = malloc(strlen(cp) + 1);
+ while (*cp) {
+ if (cp[0] == '%' && xdigit(cp[1]&0377) && xdigit(cp[2]&0377)) {
+ *dp++ = unhex(cp[1]) << 4 | unhex(cp[2]);
+ cp += 3;
+ } else
+ *dp++ = *cp++;
+ }
+ *dp = 0;
+ return dec;
+}
+#endif /* !DUMP */
diff --git a/troff/troff.d/afm.h b/troff/troff.d/afm.h
new file mode 100644
index 000000000000..5c18a38f99f7
--- /dev/null
+++ b/troff/troff.d/afm.h
@@ -0,0 +1,149 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)afm.h 1.35 (gritter) 10/5/06
+ */
+
+#ifndef TROFF_AFM_H
+#define TROFF_AFM_H
+
+enum spec {
+ SPEC_NONE = 00000,
+ SPEC_MATH = 00001,
+ SPEC_GREEK = 00002,
+ SPEC_PUNCT = 00004,
+ SPEC_LARGE = 00010,
+ SPEC_S1 = 01000,
+ SPEC_S = 02000
+};
+
+#define NOCODE ((unsigned short)-1)
+
+#define NKERNPAIRS 45
+struct kernpairs {
+ struct kernpairs *next;
+ int sorted;
+ int cnt;
+ unsigned short ch2[NKERNPAIRS];
+ short k[NKERNPAIRS];
+};
+
+struct namecache {
+ unsigned short afpos;
+ unsigned short fival[2];
+ unsigned short gid;
+};
+
+struct charpair {
+ unsigned short ch1;
+ unsigned short ch2;
+};
+
+struct feature {
+ char *name;
+ struct charpair *pairs;
+ int npairs;
+};
+
+extern struct afmtab {
+ struct Font Font;
+ char *encpath;
+ char *path;
+ char *file;
+ char *base;
+ char *fontname;
+ char *supply;
+ int *fontab;
+ short **bbtab;
+ char *kerntab;
+ unsigned short *codetab;
+ unsigned short *fitab;
+ char **nametab;
+ int *unitab;
+ int nunitab;
+ void *unimap;
+ int *encmap;
+ struct namecache *namecache;
+ int nameprime;
+ struct kernpairs *kernpairs;
+ struct charpair *gid2tr;
+ int nspace;
+ struct feature **features;
+ int rq;
+ int lineno;
+ int nchars;
+ int fichars;
+ int capheight;
+ int xheight;
+ int isFixedPitch;
+ int ascender;
+ int descender;
+ enum spec spec;
+ enum {
+ TYPE_AFM,
+ TYPE_OTF,
+ TYPE_TTF
+ } type;
+} **afmtab;
+extern int nafm;
+
+extern unsigned short **fitab;
+extern int **fontab;
+extern char **kerntab;
+extern unsigned short **codetab;
+extern struct Font **fontbase;
+
+extern int NCHARS;
+
+extern unsigned short unitsPerEm;
+
+extern int afmget(struct afmtab *, char *, size_t);
+extern int otfget(struct afmtab *, char *, size_t);
+extern struct namecache *afmnamelook(struct afmtab *, const char *);
+extern int afmgetkern(struct afmtab *, int, int);
+extern void makefont(int, char *, char *, char *, char *, int);
+extern int unitconv(int);
+extern void afmalloc(struct afmtab *, int);
+extern void afmremap(struct afmtab *);
+extern int afmmapname(const char *, enum spec);
+extern void afmaddchar(struct afmtab *, int, int, int, int, int[],
+ char *, enum spec, int);
+extern void afmaddkernpair(struct afmtab *, int, int, int);
+extern int nextprime(int n);
+extern unsigned pjw(const char *);
+extern char *afmencodepath(const char *);
+extern char *afmdecodepath(const char *);
+#ifdef DPOST
+#include <stdio.h>
+extern int otfcff(const char *, char *, size_t, size_t *, size_t *);
+extern int otft42(char *, char *, char *, size_t, FILE *);
+extern int fprintenc(FILE *, const char *);
+#endif
+
+extern struct dev dev;
+
+#define _unitconv(i) (unitsPerEm * 72 == dev.res ? (i) : unitconv(i))
+
+#endif /* !TROFF_AFM_H */
diff --git a/troff/troff.d/dev.h b/troff/troff.d/dev.h
new file mode 100644
index 000000000000..9152ed77d749
--- /dev/null
+++ b/troff/troff.d/dev.h
@@ -0,0 +1,104 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "dev.h 1.5 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)dev.h 1.15 (gritter) 9/24/06
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+/*
+ dev.h: characteristics of a typesetter
+*/
+
+#ifndef TROFF_DEV_H
+#define TROFF_DEV_H
+
+#include "global.h"
+
+struct dev {
+ unsigned filesize; /* number of bytes in file, */
+ /* excluding dev part */
+ int res; /* basic resolution in goobies/inch */
+ int hor; /* goobies horizontally */
+ int vert;
+ int unitwidth; /* size at which widths are given, in effect */
+ int nfonts; /* number of fonts physically available */
+ int nsizes; /* number of sizes it has */
+ int sizescale; /* scaling for fractional point sizes */
+ int anysize; /* device can print any size */
+ int allpunct; /* all fonts contain punctuation characters */
+ int afmfonts; /* device uses AFM fonts by default */
+ int paperwidth; /* max line length in units */
+ int paperlength; /* max paper length in units */
+ int nchtab; /* number of funny names in chtab */
+ int lchname; /* length of chname table */
+ int biggestfont; /* #chars in largest ever font */
+ int spare2; /* in case of expansion */
+ int lc_ctype; /* understands x X LC_CTYPE */
+ int encoding; /* default output encoding */
+};
+
+struct Font { /* characteristics of a font */
+ char nwfont; /* number of width entries for this font */
+ char specfont; /* 1 == special font */
+ char ligfont; /* 1 == ligatures exist on this font */
+ char kernfont; /* minimum kerning, 0 == no limit, -1 == off */
+ char namefont[10]; /* name of this font (e.g., "R" */
+ char intname[10]; /* internal name (=number) on device, in ascii */
+ int afmpos; /* afmpos-1 = position in afmtab */
+ int spacewidth; /* width of space character */
+ int cspacewidth; /* custom space width */
+};
+
+/* ligatures, ORed into ligfont */
+
+#define LFF 01
+#define LFI 02
+#define LFL 04
+#define LFFI 010
+#define LFFL 020
+
+extern void *readdesc(const char *);
+extern void *readfont(const char *, struct dev *, int);
+
+#endif /* !TROFF_DEV_H */
diff --git a/troff/troff.d/devaps/B b/troff/troff.d/devaps/B
new file mode 100644
index 000000000000..9b3f62dfef3c
--- /dev/null
+++ b/troff/troff.d/devaps/B
@@ -0,0 +1,148 @@
+#ident "@(#)B 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Times Roman Bold (with 15 characters from new disk)
+name B
+internalname 28921
+alternate_font
+ligatures fi ff fl ffi ffl 0
+charset
+A 70 2 1
+B 66 2 2
+C 68 2 3
+D 75 2 4
+E 66 2 5
+F 61 2 6
+G 70 2 7
+H 81 2 8
+I 38 2 9
+J 49 2 10
+K 70 2 11
+L 65 2 12
+M 98 2 13
+N 77 2 14
+O 73 2 15
+P 67 2 16
+Q 74 2 17
+R 70 2 18
+S 59 2 19
+T 66 2 20
+U 78 2 21
+V 71 2 22
+W 101 2 23
+X 71 2 24
+Y 70 2 25
+Z 70 2 26
+a 50 0 27
+b 50 2 28
+c 46 0 29
+d 50 2 30
+e 44 0 31
+f 35 2 32
+g 50 1 33
+h 51 2 34
+i 28 0 35
+j 31 1 36
+k 54 2 37
+l 27 2 38
+m 77 0 39
+n 50 0 40
+o 50 0 41
+p 50 1 42
+q 50 1 43
+r 39 0 44
+s 40 0 45
+t 34 2 46
+u 50 0 47
+v 40 0 48
+w 67 0 49
+x 55 0 50
+y 50 1 51
+z 47 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 104 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 52 0 72
+! 26 0 73
+% 104 0 74
+* 52 0 75
+( 43 0 101 font 21
+) 43 0 102 font 21
+/ 48 2 105 font 21
+hy 37 0 113 font 21
+- "
+em 96 0 112 font 21
+en 52 0 81
+ff 61 2 82
+fi 53 2 83
+fl 53 2 84
+Fi 82 2 85
+Fl 82 2 86
+14 78 2 91
+12 78 2 92
+34 78 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 72 0 13 font 21
+@ 96 0 14 font 21
+bu 72 0 110 font 21
+de 52 2 123
+dg 52 3 124
+dd 46 2 49 font 21
+sc 46 3 42 font 21
+[ 32 0 107 font 21
+] 32 0 108 font 21
++ 96 0 103 font 21
+\- 96 0 104 font 21
+= 96 0 106 font 21
+| 5 0 109 font 21
+sq 72 0 111 font 21
+ru 56 0 114 font 21
+fm 24 2 115 font 21
diff --git a/troff/troff.d/devaps/BI b/troff/troff.d/devaps/BI
new file mode 100644
index 000000000000..3985a926e56e
--- /dev/null
+++ b/troff/troff.d/devaps/BI
@@ -0,0 +1,139 @@
+#ident "@(#)BI 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Times Roman Bold Italic
+name BI
+internalname 28961
+ligatures fi ff fl ffi ffl 0
+charset
+A 65 2 1
+B 67 2 2
+C 73 2 3
+D 76 2 4
+E 68 2 5
+F 62 2 6
+G 70 2 7
+H 86 2 8
+I 45 2 9
+J 49 2 10
+K 75 2 11
+L 65 2 12
+M 101 2 13
+N 81 2 14
+O 75 2 15
+P 64 2 16
+Q 72 2 17
+R 69 2 18
+S 66 2 19
+T 62 2 20
+U 72 2 21
+V 64 2 22
+W 95 2 23
+X 73 2 24
+Y 65 2 25
+Z 76 2 26
+a 50 0 27
+b 50 2 28
+c 44 0 29
+d 54 2 30
+e 44 0 31
+f 36 2 32
+g 50 1 33
+h 52 2 34
+i 35 0 35
+j 35 1 36
+k 55 2 37
+l 35 2 38
+m 79 0 39
+n 53 0 40
+o 48 0 41
+p 51 1 42
+q 49 1 43
+r 39 0 44
+s 40 0 45
+t 34 2 46
+u 52 0 47
+v 39 0 48
+w 63 0 49
+x 52 0 50
+y 48 1 51
+z 44 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 73 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 52 0 72
+! 26 0 73
+% 79 0 74
+* 52 0 75
+( 41 0 76
+) 41 0 77
+/ 52 2 78
+hy 43 0 79
+- "
+em 104 0 80
+ff 66 2 82
+fi 57 2 83
+fl 66 2 84
+Fi 85 2 85
+Fl 92 2 86
+14 78 2 91
+12 76 2 92
+34 78 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 52 0 116
+@ 78 0 120
+bu 28 0 121
+de 53 2 123
+dg 52 3 124
+dd 52 2 125
+sc 52 3 126
+[ 41 0 127
+] 41 0 128
diff --git a/troff/troff.d/devaps/C b/troff/troff.d/devaps/C
new file mode 100644
index 000000000000..7442d26ca5bb
--- /dev/null
+++ b/troff/troff.d/devaps/C
@@ -0,0 +1,139 @@
+#ident "@(#)C 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# News Gothic Condensed
+name C
+internalname 19681
+ligatures fi ff fl ffi ffl 0
+charset
+A 45 2 1
+B 48 2 2
+C 46 2 3
+D 48 2 4
+E 43 2 5
+F 43 2 6
+G 50 2 7
+H 49 2 8
+I 19 2 9
+J 28 2 10
+K 47 2 11
+L 41 2 12
+M 61 2 13
+N 51 2 14
+O 49 2 15
+P 45 2 16
+Q 49 2 17
+R 46 2 18
+S 44 2 19
+T 41 2 20
+U 48 2 21
+V 43 2 22
+W 64 2 23
+X 44 2 24
+Y 44 2 25
+Z 41 2 26
+a 40 0 27
+b 42 2 28
+c 38 0 29
+d 41 2 30
+e 38 0 31
+f 26 2 32
+g 38 1 33
+h 41 2 34
+i 19 0 35
+j 20 1 36
+k 39 2 37
+l 19 2 38
+m 63 0 39
+n 42 0 40
+o 41 0 41
+p 41 1 42
+q 42 1 43
+r 30 0 44
+s 36 0 45
+t 28 2 46
+u 42 0 47
+v 39 0 48
+w 56 0 49
+x 36 0 50
+y 39 1 51
+z 34 0 52
+1 44 2 53
+2 44 2 54
+3 44 2 55
+4 44 2 56
+5 44 2 57
+6 44 2 58
+7 44 2 59
+8 44 2 60
+9 44 2 61
+0 44 2 62
+$ 44 0 63
+ct 44 3 64
+& 54 0 65
+: 22 0 66
+; 22 0 67
+. 22 0 68
+, 22 0 69
+` 22 0 70
+' 22 0 71
+? 44 0 72
+! 22 0 73
+% 66 0 74
+* 44 0 75
+( 44 0 76
+) 44 0 77
+/ 44 2 78
+hy 22 0 79
+- "
+em 88 0 80
+ff 48 2 82
+fi 43 2 83
+fl 43 2 84
+Fi 64 2 85
+Fl 64 2 86
+14 66 2 91
+12 66 2 92
+34 66 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 75 0 116
+@ 85 0 120
+bu 28 0 121
+de 51 2 123
+dg 50 3 124
+dd 51 2 125
+sc 52 3 126
+[ 25 0 127
+] 25 0 128
diff --git a/troff/troff.d/devaps/CE b/troff/troff.d/devaps/CE
new file mode 100644
index 000000000000..b9f688738708
--- /dev/null
+++ b/troff/troff.d/devaps/CE
@@ -0,0 +1,139 @@
+#ident "@(#)CE 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Century Expanded
+name CE
+internalname 6241
+ligatures fi ff fl ffi ffl 0
+charset
+A 78 2 1
+B 68 2 2
+C 67 2 3
+D 78 2 4
+E 70 2 5
+F 68 2 6
+G 79 2 7
+H 85 2 8
+I 39 2 9
+J 51 2 10
+K 79 2 11
+L 65 2 12
+M 90 2 13
+N 78 2 14
+O 68 2 15
+P 67 2 16
+Q 73 2 17
+R 73 2 18
+S 61 2 19
+T 65 2 20
+U 78 2 21
+V 73 2 22
+W 101 2 23
+X 73 2 24
+Y 73 2 25
+Z 61 2 26
+a 51 0 27
+b 56 2 28
+c 47 0 29
+d 56 2 30
+e 46 0 31
+f 39 2 32
+g 54 1 33
+h 60 2 34
+i 27 0 35
+j 37 1 36
+k 56 2 37
+l 32 2 38
+m 88 0 39
+n 59 0 40
+o 50 0 41
+p 56 1 42
+q 56 1 43
+r 46 0 44
+s 45 0 45
+t 40 2 46
+u 55 0 47
+v 52 0 48
+w 76 0 49
+x 54 0 50
+y 54 1 51
+z 45 0 52
+1 50 2 53
+2 50 2 54
+3 50 2 55
+4 50 2 56
+5 50 2 57
+6 50 2 58
+7 50 2 59
+8 50 2 60
+9 50 2 61
+0 50 2 62
+$ 50 0 63
+ct 50 3 64
+& 75 0 65
+: 25 0 66
+; 25 0 67
+. 25 0 68
+, 25 0 69
+` 25 0 70
+' 25 0 71
+? 50 0 72
+! 25 0 73
+% 100 0 74
+* 50 0 75
+( 37 0 76
+) 37 0 77
+/ 50 2 78
+hy 37 0 79
+- "
+em 100 0 80
+ff 67 2 82
+fi 57 2 83
+fl 57 2 84
+Fi 86 2 85
+Fl 86 2 86
+14 100 2 91
+12 100 2 92
+34 100 2 93
+co 64 2 111
+rg 64 2 112
+tm 64 2 113
+# 52 0 116
+@ 78 0 120
+bu 28 0 121
+de 50 2 123
+dg 50 3 124
+dd 50 2 125
+sc 50 3 126
+[ 30 0 127
+] 30 0 128
diff --git a/troff/troff.d/devaps/CI b/troff/troff.d/devaps/CI
new file mode 100644
index 000000000000..740465b537b6
--- /dev/null
+++ b/troff/troff.d/devaps/CI
@@ -0,0 +1,139 @@
+#ident "@(#)CI 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Century Bold Italic (also CK)
+name CI
+internalname 6041
+ligatures fi ff fl ffi ffl 0
+charset
+A 78 2 1
+B 81 2 2
+C 70 2 3
+D 87 2 4
+E 80 2 5
+F 76 2 6
+G 79 2 7
+H 90 2 8
+I 51 2 9
+J 65 2 10
+K 88 2 11
+L 72 2 12
+M 103 2 13
+N 87 2 14
+O 81 2 15
+P 79 2 16
+Q 81 2 17
+R 80 2 18
+S 66 2 19
+T 69 2 20
+U 83 2 21
+V 77 2 22
+W 98 2 23
+X 79 2 24
+Y 73 2 25
+Z 74 2 26
+a 60 0 27
+b 59 2 28
+c 51 0 29
+d 63 2 30
+e 50 0 31
+f 38 2 32
+g 63 1 33
+h 64 2 34
+i 38 0 35
+j 36 1 36
+k 64 2 37
+l 37 2 38
+m 91 0 39
+n 65 0 40
+o 52 0 41
+p 62 1 42
+q 59 1 43
+r 50 0 44
+s 50 0 45
+t 41 2 46
+u 64 0 47
+v 59 0 48
+w 86 0 49
+x 61 0 50
+y 60 1 51
+z 50 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 84 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 52 0 72
+! 32 0 73
+% 104 0 74
+* 52 0 75
+( 52 0 76
+) 52 0 77
+/ 52 2 78
+hy 40 0 79
+- "
+em 104 0 80
+ff 73 2 82
+fi 73 2 83
+fl 74 2 84
+Fi 102 2 85
+Fl 103 2 86
+14 104 2 91
+12 104 2 92
+34 104 2 93
+co 64 2 111
+rg 64 2 112
+tm 64 2 113
+# 52 0 116
+@ 104 0 120
+bu 28 0 121
+de 52 2 123
+dg 52 3 124
+dd 52 2 125
+sc 52 3 126
+[ 52 0 127
+] 52 0 128
diff --git a/troff/troff.d/devaps/CT b/troff/troff.d/devaps/CT
new file mode 100644
index 000000000000..2c005aee38e6
--- /dev/null
+++ b/troff/troff.d/devaps/CT
@@ -0,0 +1,132 @@
+#ident "@(#)CT 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Courier Typewriter
+name CT
+internalname 8301
+spacewidth 63
+max_range 1
+charset
+A 63 2 1
+B 63 2 2
+C 63 2 3
+D 63 2 4
+E 63 2 5
+F 63 2 6
+G 63 2 7
+H 63 2 8
+I 63 2 9
+J 63 2 10
+K 63 2 11
+L 63 2 12
+M 63 2 13
+N 63 2 14
+O 63 2 15
+P 63 2 16
+Q 63 2 17
+R 63 2 18
+S 63 2 19
+T 63 2 20
+U 63 2 21
+V 63 2 22
+W 63 2 23
+X 63 2 24
+Y 63 2 25
+Z 63 2 26
+a 63 0 27
+b 63 2 28
+c 63 0 29
+d 63 2 30
+e 63 0 31
+f 63 2 32
+g 63 1 33
+h 63 2 34
+i 63 0 35
+j 63 1 36
+k 63 2 37
+l 63 2 38
+m 63 0 39
+n 63 0 40
+o 63 0 41
+p 63 1 42
+q 63 1 43
+r 63 0 44
+s 63 0 45
+t 63 2 46
+u 63 0 47
+v 63 0 48
+w 63 0 49
+x 63 0 50
+y 63 1 51
+z 63 0 52
+1 63 2 53
+2 63 2 54
+3 63 2 55
+4 63 2 56
+5 63 2 57
+6 63 2 58
+7 63 2 59
+8 63 2 60
+9 63 2 61
+0 63 2 62
+$ 63 0 63
+ct 63 3 64
+& 63 0 65
+: 63 0 66
+; 63 0 67
+. 63 0 68
+, 63 0 69
+" 63 0 70
+' 63 0 71
+? 63 0 72
+! 63 0 73
+% 63 0 74
+* 63 0 75
+( 63 0 76
+) 63 0 77
+/ 63 2 78
+sl "
+hy 63 0 79
+- "
+em 63 0 80
+_ 63 0 109
+| 63 0 110
+# 63 0 116
+@ 63 0 120
+bu 28 0 121
+de 63 2 123
+dg 63 3 124
+dd 63 2 125
+sc 63 3 126
+[ 63 0 127
+] 63 0 128
diff --git a/troff/troff.d/devaps/CW b/troff/troff.d/devaps/CW
new file mode 100644
index 000000000000..698c1c9193a6
--- /dev/null
+++ b/troff/troff.d/devaps/CW
@@ -0,0 +1,147 @@
+#ident "@(#)CW 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Constant Width (also PO)
+name CW
+internalname 10941
+spacewidth 68
+max_range 2
+charset
+A 68 2 1
+B 68 2 2
+C 68 2 3
+D 68 2 4
+E 68 2 5
+F 68 2 6
+G 68 2 7
+H 68 2 8
+I 68 2 9
+J 68 2 10
+K 68 2 11
+L 68 2 12
+M 68 2 13
+N 68 2 14
+O 68 2 15
+P 68 2 16
+Q 68 2 17
+R 68 2 18
+S 68 2 19
+T 68 2 20
+U 68 2 21
+V 68 2 22
+W 68 2 23
+X 68 2 24
+Y 68 2 25
+Z 68 2 26
+a 68 0 27
+b 68 2 28
+c 68 0 29
+d 68 2 30
+e 68 0 31
+f 68 2 32
+g 68 1 33
+h 68 2 34
+i 68 0 35
+j 68 1 36
+k 68 2 37
+l 68 2 38
+m 68 0 39
+n 68 0 40
+o 68 0 41
+p 68 1 42
+q 68 1 43
+r 68 0 44
+s 68 0 45
+t 68 2 46
+u 68 0 47
+v 68 0 48
+w 68 0 49
+x 68 0 50
+y 68 1 51
+z 68 0 52
+1 68 2 53
+2 68 2 54
+3 68 2 55
+4 68 2 56
+5 68 2 57
+6 68 2 58
+7 68 2 59
+8 68 2 60
+9 68 2 61
+0 68 2 62
+$ 68 0 63
+ct 68 3 64
+& 68 0 65
+: 68 0 66
+; 68 0 67
+. 68 0 68
+, 68 0 69
+` 68 0 70
+' 68 0 71
+? 68 0 72
+! 68 0 73
+% 68 0 74
+* 68 0 75
+( 68 0 76
+) 68 0 77
+/ 68 2 78
+sl "
+hy 68 0 79
+- "
+= 68 0 80
++ 68 0 81
+no 68 0 82
+< 68 0 83
+> 68 0 84
+{ 68 0 85
+} 68 0 86
+^ 68 0 91
+~ 68 0 92
+" 68 0 93
+fm 68 2 94
+_ 68 0 109
+ul "
+| 68 0 110
+or "
+lh 68 2 111
+\ 68 0 112
+# 68 0 116
+@ 68 0 120
+sq 68 0 121
+-> 68 0 122
+<- 68 0 123
+dg 68 3 124
+ua 68 3 125
+da 68 3 126
+[ 68 0 127
+] 68 0 128
diff --git a/troff/troff.d/devaps/CX b/troff/troff.d/devaps/CX
new file mode 100644
index 000000000000..3e1a727498e7
--- /dev/null
+++ b/troff/troff.d/devaps/CX
@@ -0,0 +1,140 @@
+#ident "@(#)CX 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# News Gothic Condensed Italic
+name CX
+internalname 19681
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+charset
+A 45 2 1
+B 48 2 2
+C 46 2 3
+D 48 2 4
+E 43 2 5
+F 43 2 6
+G 50 2 7
+H 49 2 8
+I 19 2 9
+J 28 2 10
+K 47 2 11
+L 41 2 12
+M 61 2 13
+N 51 2 14
+O 49 2 15
+P 45 2 16
+Q 49 2 17
+R 46 2 18
+S 44 2 19
+T 41 2 20
+U 48 2 21
+V 43 2 22
+W 64 2 23
+X 44 2 24
+Y 44 2 25
+Z 41 2 26
+a 40 0 27
+b 42 2 28
+c 38 0 29
+d 41 2 30
+e 38 0 31
+f 26 2 32
+g 38 1 33
+h 41 2 34
+i 19 0 35
+j 20 1 36
+k 39 2 37
+l 19 2 38
+m 63 0 39
+n 42 0 40
+o 41 0 41
+p 41 1 42
+q 42 1 43
+r 30 0 44
+s 36 0 45
+t 28 2 46
+u 42 0 47
+v 39 0 48
+w 56 0 49
+x 36 0 50
+y 39 1 51
+z 34 0 52
+1 44 2 53
+2 44 2 54
+3 44 2 55
+4 44 2 56
+5 44 2 57
+6 44 2 58
+7 44 2 59
+8 44 2 60
+9 44 2 61
+0 44 2 62
+$ 44 0 63
+ct 44 3 64
+& 54 0 65
+: 22 0 66
+; 22 0 67
+. 22 0 68
+, 22 0 69
+` 22 0 70
+' 22 0 71
+? 44 0 72
+! 22 0 73
+% 66 0 74
+* 44 0 75
+( 44 0 76
+) 44 0 77
+/ 44 2 78
+hy 22 0 79
+- "
+em 88 0 80
+ff 48 2 82
+fi 43 2 83
+fl 43 2 84
+Fi 64 2 85
+Fl 64 2 86
+14 66 2 91
+12 66 2 92
+34 66 2 93
+co 50 2 111 slant 0
+rg 50 2 112 slant 0
+tm 50 2 113 slant 0
+# 75 0 116
+@ 85 0 120
+bu 28 0 121 slant 0
+de 51 2 123 slant 0
+dg 50 3 124
+dd 51 2 125
+sc 52 3 126
+[ 25 0 127
+] 25 0 128
diff --git a/troff/troff.d/devaps/DESC b/troff/troff.d/devaps/DESC
new file mode 100644
index 000000000000..deb5416da1fc
--- /dev/null
+++ b/troff/troff.d/devaps/DESC
@@ -0,0 +1,67 @@
+#ident "@(#)DESC 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+fonts 8 R I B H CW S S1 GR
+sizes 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 24 26 28 30 32 34 36 40 44 48 0
+res 723
+hor 1
+vert 1
+unitwidth 10
+paperwidth 6120
+biggestfont 109
+charset
+\- \_
+** *A *B *C *D *E *F *G *H *I *K *L *M *N *O *P *Q *R *S
+*T *U *V *W *X *Y *Z *a *b *c *d *e *f *g *h *i
+*k *l *m *n *o *p *q *r *s *t *u
+*w *x *y *z +- -> <- <=
+== >= aa
+LH LV
+ap br bu bv ca
+ci co ct cu dd de dg di em
+eq es fm ga gr hy
+ib if ip is lh mi mo
+mu no or pd pl pt rg rh ru
+sb sc sl sp sq sr tm ts
+~= ul rn en
+lf rf lc rc lt rt lb rb
+lk rk !=
+ua da 12
+bx 14 34
+ff fi fl Fi Fl
+ps !< !> as os tf bc ld rd pp ra an =. 4d =:
+-+ gp =p cy
+le ge el eg LE GE EL EG <> ><
+RC TR RB CB Sl
+\' \`
+xe xh xk cs vs ob rs dq
diff --git a/troff/troff.d/devaps/G b/troff/troff.d/devaps/G
new file mode 100644
index 000000000000..5f02b7cdd7c7
--- /dev/null
+++ b/troff/troff.d/devaps/G
@@ -0,0 +1,139 @@
+#ident "@(#)G 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Geneva Regular (also Helvetica Regular)
+name G
+internalname 12641
+ligatures fi ff fl ffi ffl 0
+charset
+A 64 2 1
+B 64 2 2
+C 68 2 3
+D 66 2 4
+E 60 2 5
+F 60 2 6
+G 70 2 7
+H 63 2 8
+I 24 2 9
+J 51 2 10
+K 64 2 11
+L 56 2 12
+M 80 2 13
+N 66 2 14
+O 74 2 15
+P 62 2 16
+Q 76 2 17
+R 66 2 18
+S 64 2 19
+T 56 2 20
+U 66 2 21
+V 64 2 22
+W 90 2 23
+X 64 2 24
+Y 66 2 25
+Z 60 2 26
+a 56 0 27
+b 56 2 28
+c 54 0 29
+d 56 2 30
+e 56 0 31
+f 30 2 32
+g 56 1 33
+h 54 2 34
+i 24 0 35
+j 24 1 36
+k 52 2 37
+l 24 2 38
+m 76 0 39
+n 50 0 40
+o 56 0 41
+p 56 1 42
+q 56 1 43
+r 34 0 44
+s 52 0 45
+t 32 2 46
+u 50 0 47
+v 48 0 48
+w 70 0 49
+x 52 0 50
+y 50 1 51
+z 48 0 52
+1 56 2 53
+2 56 2 54
+3 56 2 55
+4 56 2 56
+5 56 2 57
+6 56 2 58
+7 56 2 59
+8 56 2 60
+9 56 2 61
+0 56 2 62
+$ 56 0 63
+ct 56 3 64
+& 64 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 52 0 72
+! 28 0 73
+% 84 0 74
+* 56 0 75
+( 36 0 76
+) 36 0 77
+/ 56 2 78
+hy 32 0 79
+- "
+em 112 0 80
+ff 53 2 82
+fi 48 2 83
+fl 48 2 84
+Fi 71 2 85
+Fl 71 2 86
+14 84 2 91
+12 84 2 92
+34 84 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 75 0 116
+@ 84 0 120
+bu 28 0 121
+de 56 2 123
+dg 56 3 124
+dd 56 2 125
+sc 56 3 126
+[ 32 0 127
+] 32 0 128
diff --git a/troff/troff.d/devaps/GB b/troff/troff.d/devaps/GB
new file mode 100644
index 000000000000..13768f637c62
--- /dev/null
+++ b/troff/troff.d/devaps/GB
@@ -0,0 +1,90 @@
+#ident "@(#)GB 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Greek Bold
+name GB
+internalname 14121
+alternate_font
+special
+max_range 2
+charset
+*A 78 2 1
+*B 78 2 2
+*G 64 2 3
+*D 74 2 4
+*E 77 2 5
+*Z 68 2 6
+*Y 88 2 7
+*H 66 2 8
+*I 46 2 9
+*K 87 2 10
+*L 72 2 11
+*M 102 2 12
+*N 90 2 13
+*C 70 2 14
+*O 76 2 15
+*P 82 2 16
+*R 72 2 17
+*S 66 2 18
+*T 78 2 19
+*F 72 2 21
+*X 90 2 22
+*a 60 0 27
+*b 60 3 28
+*g 61 3 29
+*d 42 2 30
+*e 34 0 31
+*z 46 3 32
+*y 50 1 33
+*h 44 2 34
+*i 30 0 35
+*k 44 0 36
+*l 54 2 37
+*m 56 1 38
+*n 42 0 39
+*c 44 3 40
+*o 42 0 41
+*p 62 0 42
+*r 46 1 43
+*s 54 0 44
+*t 50 0 45
+*u 46 0 46
+*f 60 3 47
+*x 61 3 48
+*q 62 3 49
+*w 64 0 50
+pd 40 2 52
+gr 80 2 53
+xe 38 0 98 font 13961
+xh 61 2 101
+xk 48 0 103 font 13961
diff --git a/troff/troff.d/devaps/GI b/troff/troff.d/devaps/GI
new file mode 100644
index 000000000000..cf6d7a87b1ae
--- /dev/null
+++ b/troff/troff.d/devaps/GI
@@ -0,0 +1,141 @@
+#ident "@(#)GI 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Geneva Italic (also Helvetica Italic)
+name GI
+internalname 12641
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+alternate_font
+charset
+A 64 2 1
+B 64 2 2
+C 68 2 3
+D 66 2 4
+E 60 2 5
+F 60 2 6
+G 70 2 7
+H 63 2 8
+I 24 2 9
+J 51 2 10
+K 64 2 11
+L 56 2 12
+M 80 2 13
+N 66 2 14
+O 74 2 15
+P 62 2 16
+Q 76 2 17
+R 66 2 18
+S 64 2 19
+T 56 2 20
+U 66 2 21
+V 64 2 22
+W 90 2 23
+X 64 2 24
+Y 66 2 25
+Z 60 2 26
+a 56 0 27
+b 56 2 28
+c 54 0 29
+d 56 2 30
+e 56 0 31
+f 30 2 32
+g 56 1 33
+h 54 2 34
+i 24 0 35
+j 24 1 36
+k 52 2 37
+l 24 2 38
+m 76 0 39
+n 50 0 40
+o 56 0 41
+p 56 1 42
+q 56 1 43
+r 34 0 44
+s 52 0 45
+t 32 2 46
+u 50 0 47
+v 48 0 48
+w 70 0 49
+x 52 0 50
+y 50 1 51
+z 48 0 52
+1 56 2 53
+2 56 2 54
+3 56 2 55
+4 56 2 56
+5 56 2 57
+6 56 2 58
+7 56 2 59
+8 56 2 60
+9 56 2 61
+0 56 2 62
+$ 56 0 63
+ct 56 3 64
+& 64 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 52 0 72
+! 28 0 73
+% 84 0 74
+* 56 0 75
+( 36 0 76
+) 36 0 77
+/ 56 2 78
+hy 32 0 79
+- "
+em 112 0 80
+ff 53 2 82
+fi 48 2 83
+fl 48 2 84
+Fi 71 2 85
+Fl 71 2 86
+14 84 2 91
+12 84 2 92
+34 84 2 93
+co 50 2 111 slant 0
+rg 50 2 112 slant 0
+tm 50 2 113 slant 0
+# 75 0 116
+@ 84 0 120
+bu 28 0 121 slant 0
+de 56 2 123 slant 0
+dg 56 3 124
+dd 56 2 125
+sc 56 3 126
+[ 32 0 127
+] 32 0 128
diff --git a/troff/troff.d/devaps/GR b/troff/troff.d/devaps/GR
new file mode 100644
index 000000000000..d7607edff761
--- /dev/null
+++ b/troff/troff.d/devaps/GR
@@ -0,0 +1,89 @@
+#ident "@(#)GR 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Greek
+name GR
+internalname 13961
+special
+max_range 2
+charset
+*A 68 2 1
+*B 62 2 2
+*G 58 2 3 max_range 3
+*D 66 2 4
+*E 61 2 5
+*Z 55 2 6
+*Y 75 2 7
+*H 63 2 8
+*I 37 2 9
+*K 75 2 10
+*L 67 2 11
+*M 84 2 12
+*N 74 2 13
+*C 66 2 14
+*O 62 2 15
+*P 76 2 16 max_range 3
+*R 57 2 17
+*S 62 2 18 max_range 3
+*T 62 2 19
+*F 65 2 21
+*X 72 2 22
+*a 58 0 27
+*b 55 3 28
+*g 58 3 29
+*d 41 2 30
+*e 33 0 31
+*z 39 3 32
+*y 47 1 33
+*h 43 2 34
+*i 26 0 35
+*k 41 0 36
+*l 51 2 37
+*m 54 1 38
+*n 40 0 39
+*c 43 3 40
+*o 41 0 41
+*p 59 0 42
+*r 49 1 43
+*s 50 0 44
+*t 46 0 45
+*u 42 0 46
+*f 58 3 47
+*x 58 3 48
+*q 59 3 49
+*w 61 0 50
+pd 50 2 52
+gr 68 2 53
+xe 38 0 98
+xh 58 2 101
+xk 48 0 103
diff --git a/troff/troff.d/devaps/GS b/troff/troff.d/devaps/GS
new file mode 100644
index 000000000000..9fbcd3ce05c5
--- /dev/null
+++ b/troff/troff.d/devaps/GS
@@ -0,0 +1,135 @@
+#ident "@(#)GS 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# German Script
+name GS
+internalname 41
+alternate_font
+max_range 2
+charset
+A 71 2 1
+B 75 2 2
+C 63 2 3
+D 79 2 4
+E 66 2 5
+F 69 2 6
+G 74 2 7
+H 69 2 8
+I 67 2 9
+J 66 2 10
+K 68 2 11
+L 59 2 12
+M 99 2 13
+N 77 2 14
+O 78 2 15
+P 74 2 16
+Q 82 2 17
+R 72 2 18
+S 77 2 19
+T 67 2 20
+U 65 2 21
+V 73 2 22
+W 92 2 23
+X 66 2 24
+Y 67 2 25
+Z 65 2 26
+a 48 0 27
+b 47 2 28
+c 34 0 29
+d 46 2 30
+e 38 0 31
+f 29 2 32
+g 44 1 33
+h 47 2 34
+i 30 0 35
+j 28 1 36
+k 36 2 37
+l 29 2 38
+m 78 0 39
+n 55 0 40
+o 46 0 41
+p 50 1 42
+q 46 1 43
+r 42 0 44
+s 48 0 45
+t 31 2 46
+u 55 0 47
+v 45 0 48
+w 69 0 49
+x 42 0 50
+y 47 1 51
+z 38 0 52
+1 52 2 53 font 18001
+2 52 2 54 font 18001
+3 52 2 55 font 18001
+4 52 2 56 font 18001
+5 52 2 57 font 18001
+6 52 2 58 font 18001
+7 52 2 59 font 18001
+8 52 2 60 font 18001
+9 52 2 61 font 18001
+0 52 2 62 font 18001
+$ 52 0 63 font 18001
+ct 52 3 64 font 18001
+& 75 0 65 font 18081
+: 26 0 66 font 18001
+; 26 0 67 font 18001
+. 26 0 68 font 18001
+, 26 0 69 font 18001
+` 26 0 70 font 18001
+' 26 0 71 font 18001
+? 43 0 72 font 18001
+! 26 0 73 font 18001
+% 75 0 74 font 18001
+* 52 0 75 font 18001
+( 34 0 76 font 18001
+) 34 0 77 font 18001
+/ 52 2 78 font 18001
+hy 34 0 79 font 18001
+- "
+em 104 0 80 font 18001
+14 78 2 91 font 18001
+12 78 2 92 font 18001
+34 78 2 93 font 18001
+co 50 2 111 font 18001
+rg 50 2 112 font 18001
+tm 50 2 113 font 18001
+# 78 0 116 font 18001
+@ 104 0 120 font 18001
+bu 28 0 121 font 18001
+de 52 2 123 font 18001
+dg 52 3 124 font 18001
+dd 52 2 125 font 18001
+sc 52 3 126 font 18001
+[ 29 0 127 font 18001
+] 30 0 128 font 18001
diff --git a/troff/troff.d/devaps/H b/troff/troff.d/devaps/H
new file mode 100644
index 000000000000..df55b2cd390d
--- /dev/null
+++ b/troff/troff.d/devaps/H
@@ -0,0 +1,139 @@
+#ident "@(#)H 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Helvetica Regular (also Geneva Regular)
+name H
+internalname 12641
+ligatures fi ff fl ffi ffl 0
+charset
+A 64 2 1
+B 64 2 2
+C 68 2 3
+D 66 2 4
+E 60 2 5
+F 60 2 6
+G 70 2 7
+H 63 2 8
+I 24 2 9
+J 51 2 10
+K 64 2 11
+L 56 2 12
+M 80 2 13
+N 66 2 14
+O 74 2 15
+P 62 2 16
+Q 76 2 17
+R 66 2 18
+S 64 2 19
+T 56 2 20
+U 66 2 21
+V 64 2 22
+W 90 2 23
+X 64 2 24
+Y 66 2 25
+Z 60 2 26
+a 56 0 27
+b 56 2 28
+c 54 0 29
+d 56 2 30
+e 56 0 31
+f 30 2 32
+g 56 1 33
+h 54 2 34
+i 24 0 35
+j 24 1 36
+k 52 2 37
+l 24 2 38
+m 76 0 39
+n 50 0 40
+o 56 0 41
+p 56 1 42
+q 56 1 43
+r 34 0 44
+s 52 0 45
+t 32 2 46
+u 50 0 47
+v 48 0 48
+w 70 0 49
+x 52 0 50
+y 50 1 51
+z 48 0 52
+1 56 2 53
+2 56 2 54
+3 56 2 55
+4 56 2 56
+5 56 2 57
+6 56 2 58
+7 56 2 59
+8 56 2 60
+9 56 2 61
+0 56 2 62
+$ 56 0 63
+ct 56 3 64
+& 64 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 52 0 72
+! 28 0 73
+% 84 0 74
+* 56 0 75
+( 36 0 76
+) 36 0 77
+/ 56 2 78
+hy 32 0 79
+- "
+em 112 0 80
+ff 53 2 82
+fi 48 2 83
+fl 48 2 84
+Fi 71 2 85
+Fl 71 2 86
+14 84 2 91
+12 84 2 92
+34 84 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 75 0 116
+@ 84 0 120
+bu 28 0 121
+de 56 2 123
+dg 56 3 124
+dd 56 2 125
+sc 56 3 126
+[ 32 0 127
+] 32 0 128
diff --git a/troff/troff.d/devaps/HB b/troff/troff.d/devaps/HB
new file mode 100644
index 000000000000..ef1a515ee173
--- /dev/null
+++ b/troff/troff.d/devaps/HB
@@ -0,0 +1,139 @@
+#ident "@(#)HB 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Helvetica Black (also Helvetica Medium, Geneva Medium)
+name HB
+internalname 12561
+ligatures fi ff fl ffi ffl 0
+charset
+A 66 2 1
+B 66 2 2
+C 70 2 3
+D 70 2 4
+E 64 2 5
+F 62 2 6
+G 74 2 7
+H 66 2 8
+I 28 2 9
+J 54 2 10
+K 68 2 11
+L 56 2 12
+M 80 2 13
+N 68 2 14
+O 74 2 15
+P 62 2 16
+Q 76 2 17
+R 64 2 18
+S 64 2 19
+T 62 2 20
+U 68 2 21
+V 64 2 22
+W 90 2 23
+X 62 2 24
+Y 62 2 25
+Z 62 2 26
+a 56 0 27
+b 60 2 28
+c 56 0 29
+d 60 2 30
+e 58 0 31
+f 36 2 32
+g 60 1 33
+h 56 2 34
+i 26 0 35
+j 26 1 36
+k 58 2 37
+l 26 2 38
+m 84 0 39
+n 58 0 40
+o 60 0 41
+p 60 1 42
+q 60 1 43
+r 38 0 44
+s 52 0 45
+t 36 2 46
+u 56 0 47
+v 52 0 48
+w 78 0 49
+x 56 0 50
+y 54 1 51
+z 50 0 52
+1 60 2 53
+2 60 2 54
+3 60 2 55
+4 60 2 56
+5 60 2 57
+6 60 2 58
+7 60 2 59
+8 60 2 60
+9 60 2 61
+0 60 2 62
+$ 60 0 63
+ct 60 3 64
+& 70 0 65
+: 30 0 66
+; 30 0 67
+. 30 0 68
+, 30 0 69
+` 30 0 70
+' 30 0 71
+? 30 0 72
+! 30 0 73
+% 90 0 74
+* 30 0 75
+( 32 0 76
+) 32 0 77
+/ 60 2 78
+hy 30 0 79
+- "
+em 120 0 80
+ff 61 2 82
+fi 54 2 83
+fl 54 2 84
+Fi 83 2 85
+Fl 83 2 86
+14 90 2 91
+12 90 2 92
+34 90 2 93
+co 64 2 111
+rg 64 2 112
+tm 64 2 113
+# 90 0 116
+@ 90 0 120
+bu 28 0 121
+de 30 2 123
+dg 60 3 124
+dd 60 2 125
+sc 60 3 126
+[ 30 0 127
+] 30 0 128
diff --git a/troff/troff.d/devaps/HI b/troff/troff.d/devaps/HI
new file mode 100644
index 000000000000..0c984a856afa
--- /dev/null
+++ b/troff/troff.d/devaps/HI
@@ -0,0 +1,141 @@
+#ident "@(#)HI 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Helvetica Italic (also Geneva Italic)
+name HI
+internalname 12641
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+alternate_font
+charset
+A 64 2 1
+B 64 2 2
+C 68 2 3
+D 66 2 4
+E 60 2 5
+F 60 2 6
+G 70 2 7
+H 63 2 8
+I 24 2 9
+J 51 2 10
+K 64 2 11
+L 56 2 12
+M 80 2 13
+N 66 2 14
+O 74 2 15
+P 62 2 16
+Q 76 2 17
+R 66 2 18
+S 64 2 19
+T 56 2 20
+U 66 2 21
+V 64 2 22
+W 90 2 23
+X 64 2 24
+Y 66 2 25
+Z 60 2 26
+a 56 0 27
+b 56 2 28
+c 54 0 29
+d 56 2 30
+e 56 0 31
+f 30 2 32
+g 56 1 33
+h 54 2 34
+i 24 0 35
+j 24 1 36
+k 52 2 37
+l 24 2 38
+m 76 0 39
+n 50 0 40
+o 56 0 41
+p 56 1 42
+q 56 1 43
+r 34 0 44
+s 52 0 45
+t 32 2 46
+u 50 0 47
+v 48 0 48
+w 70 0 49
+x 52 0 50
+y 50 1 51
+z 48 0 52
+1 56 2 53
+2 56 2 54
+3 56 2 55
+4 56 2 56
+5 56 2 57
+6 56 2 58
+7 56 2 59
+8 56 2 60
+9 56 2 61
+0 56 2 62
+$ 56 0 63
+ct 56 3 64
+& 64 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 52 0 72
+! 28 0 73
+% 84 0 74
+* 56 0 75
+( 36 0 76
+) 36 0 77
+/ 56 2 78
+hy 32 0 79
+- "
+em 112 0 80
+ff 53 2 82
+fi 48 2 83
+fl 48 2 84
+Fi 71 2 85
+Fl 71 2 86
+14 84 2 91
+12 84 2 92
+34 84 2 93
+co 50 2 111 slant 0
+rg 50 2 112 slant 0
+tm 50 2 113 slant 0
+# 75 0 116
+@ 84 0 120
+bu 28 0 121 slant 0
+de 56 2 123 slant 0
+dg 56 3 124
+dd 56 2 125
+sc 56 3 126
+[ 32 0 127
+] 32 0 128
diff --git a/troff/troff.d/devaps/HK b/troff/troff.d/devaps/HK
new file mode 100644
index 000000000000..3e5677903ce1
--- /dev/null
+++ b/troff/troff.d/devaps/HK
@@ -0,0 +1,140 @@
+#ident "@(#)HK 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Helvetica Light Italic 2
+name HK
+internalname 12491
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+charset
+A 65 2 1
+B 64 2 2
+C 70 2 3
+D 69 2 4
+E 60 2 5
+F 56 2 6
+G 75 2 7
+H 69 2 8
+I 21 2 9
+J 48 2 10
+K 65 2 11
+L 54 2 12
+M 79 2 13
+N 67 2 14
+O 75 2 15
+P 60 2 16
+Q 75 2 17
+R 65 2 18
+S 61 2 19
+T 56 2 20
+U 69 2 21
+V 63 2 22
+W 89 2 23
+X 61 2 24
+Y 62 2 25
+Z 62 2 26
+a 52 0 27
+b 58 2 28
+c 52 0 29
+d 58 2 30
+e 53 0 31
+f 29 2 32
+g 58 1 33
+h 54 2 34
+i 21 0 35
+j 22 1 36
+k 50 2 37
+l 21 2 38
+m 81 0 39
+n 54 0 40
+o 53 0 41
+p 58 1 42
+q 58 1 43
+r 32 0 44
+s 49 0 45
+t 32 2 46
+u 54 0 47
+v 49 0 48
+w 73 0 49
+x 49 0 50
+y 49 1 51
+z 49 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 63 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 50 0 72
+! 21 0 73
+% 85 0 74
+* 38 0 75
+( 30 0 76
+) 30 0 77
+/ 38 2 78
+hy 27 0 79
+- "
+em 104 0 80
+ff 52 2 82
+fi 47 2 83
+fl 47 2 84
+Fi 70 2 85
+Fl 70 2 86
+14 88 2 91
+12 88 2 92
+34 88 2 93
+co 81 2 111 slant 0
+rg 81 2 112 slant 0
+tm 60 2 113 slant 0
+# 78 0 116
+@ 100 0 120
+bu 28 0 121 slant 0
+de 41 2 123 slant 0
+dg 52 3 124
+dd 52 2 125
+sc 52 3 126
+[ 34 0 127
+] 34 0 128
diff --git a/troff/troff.d/devaps/HL b/troff/troff.d/devaps/HL
new file mode 100644
index 000000000000..a86a8a12efee
--- /dev/null
+++ b/troff/troff.d/devaps/HL
@@ -0,0 +1,139 @@
+#ident "@(#)HL 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Helvetica Light 2
+name HL
+internalname 12491
+ligatures fi ff fl ffi ffl 0
+charset
+A 65 2 1
+B 64 2 2
+C 70 2 3
+D 69 2 4
+E 60 2 5
+F 56 2 6
+G 75 2 7
+H 69 2 8
+I 21 2 9
+J 48 2 10
+K 65 2 11
+L 54 2 12
+M 79 2 13
+N 67 2 14
+O 75 2 15
+P 60 2 16
+Q 75 2 17
+R 65 2 18
+S 61 2 19
+T 56 2 20
+U 69 2 21
+V 63 2 22
+W 89 2 23
+X 61 2 24
+Y 62 2 25
+Z 62 2 26
+a 52 0 27
+b 58 2 28
+c 52 0 29
+d 58 2 30
+e 53 0 31
+f 29 2 32
+g 58 1 33
+h 54 2 34
+i 21 0 35
+j 22 1 36
+k 50 2 37
+l 21 2 38
+m 81 0 39
+n 54 0 40
+o 53 0 41
+p 58 1 42
+q 58 1 43
+r 32 0 44
+s 49 0 45
+t 32 2 46
+u 54 0 47
+v 49 0 48
+w 73 0 49
+x 49 0 50
+y 49 1 51
+z 49 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 63 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 50 0 72
+! 21 0 73
+% 85 0 74
+* 38 0 75
+( 30 0 76
+) 30 0 77
+/ 38 2 78
+hy 27 0 79
+- "
+em 104 0 80
+ff 52 2 82
+fi 47 2 83
+fl 47 2 84
+Fi 70 2 85
+Fl 70 2 86
+14 88 2 91
+12 88 2 92
+34 88 2 93
+co 81 2 111
+rg 81 2 112
+tm 60 2 113
+# 78 0 116
+@ 100 0 120
+bu 28 0 121
+de 41 2 123
+dg 52 3 124
+dd 52 2 125
+sc 52 3 126
+[ 34 0 127
+] 34 0 128
diff --git a/troff/troff.d/devaps/HX b/troff/troff.d/devaps/HX
new file mode 100644
index 000000000000..6b816e0c6c17
--- /dev/null
+++ b/troff/troff.d/devaps/HX
@@ -0,0 +1,140 @@
+#ident "@(#)HX 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Helvetica Black Italic
+name HX
+internalname 12561
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+charset
+A 66 2 1
+B 66 2 2
+C 70 2 3
+D 70 2 4
+E 64 2 5
+F 62 2 6
+G 74 2 7
+H 66 2 8
+I 28 2 9
+J 54 2 10
+K 68 2 11
+L 56 2 12
+M 80 2 13
+N 68 2 14
+O 74 2 15
+P 62 2 16
+Q 76 2 17
+R 64 2 18
+S 64 2 19
+T 62 2 20
+U 68 2 21
+V 64 2 22
+W 90 2 23
+X 62 2 24
+Y 62 2 25
+Z 62 2 26
+a 56 0 27
+b 60 2 28
+c 56 0 29
+d 60 2 30
+e 58 0 31
+f 36 2 32
+g 60 1 33
+h 56 2 34
+i 26 0 35
+j 26 1 36
+k 58 2 37
+l 26 2 38
+m 84 0 39
+n 58 0 40
+o 60 0 41
+p 60 1 42
+q 60 1 43
+r 38 0 44
+s 52 0 45
+t 36 2 46
+u 56 0 47
+v 52 0 48
+w 78 0 49
+x 56 0 50
+y 54 1 51
+z 50 0 52
+1 60 2 53
+2 60 2 54
+3 60 2 55
+4 60 2 56
+5 60 2 57
+6 60 2 58
+7 60 2 59
+8 60 2 60
+9 60 2 61
+0 60 2 62
+$ 60 0 63
+ct 60 3 64
+& 70 0 65
+: 30 0 66
+; 30 0 67
+. 30 0 68
+, 30 0 69
+` 30 0 70
+' 30 0 71
+? 30 0 72
+! 30 0 73
+% 90 0 74
+* 30 0 75
+( 32 0 76
+) 32 0 77
+/ 60 2 78
+hy 30 0 79
+- "
+em 120 0 80
+ff 61 2 82
+fi 54 2 83
+fl 54 2 84
+Fi 83 2 85
+Fl 83 2 86
+14 90 2 91
+12 90 2 92
+34 90 2 93
+co 64 2 111 slant 0
+rg 64 2 112 slant 0
+tm 64 2 113 slant 0
+# 90 0 116
+@ 90 0 120
+bu 28 0 121 slant 0
+de 30 2 123 slant 0
+dg 60 3 124
+dd 60 2 125
+sc 60 3 126
+[ 30 0 127
+] 30 0 128
diff --git a/troff/troff.d/devaps/I b/troff/troff.d/devaps/I
new file mode 100644
index 000000000000..414775aac63d
--- /dev/null
+++ b/troff/troff.d/devaps/I
@@ -0,0 +1,148 @@
+#ident "@(#)I 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Times Roman Italic (with 15 characters from new disk)
+name I
+internalname 29241
+alternate_font
+ligatures fi ff fl ffi ffl 0
+charset
+A 73 2 1
+B 65 2 2
+C 69 2 3
+D 73 2 4
+E 70 2 5
+F 63 2 6
+G 72 2 7
+H 82 2 8
+I 40 2 9
+J 52 2 10
+K 72 2 11
+L 62 2 12
+M 97 2 13
+N 79 2 14
+O 72 2 15
+P 63 2 16
+Q 74 2 17
+R 75 2 18
+S 63 2 19
+T 69 2 20
+U 72 2 21
+V 68 2 22
+W 94 2 23
+X 71 2 24
+Y 69 2 25
+Z 72 2 26
+a 52 0 27
+b 51 2 28
+c 43 0 29
+d 55 2 30
+e 44 0 31
+f 36 2 32
+g 50 1 33
+h 55 2 34
+i 30 0 35
+j 34 1 36
+k 57 2 37
+l 32 2 38
+m 82 0 39
+n 51 0 40
+o 51 0 41
+p 53 1 42
+q 52 1 43
+r 40 0 44
+s 41 0 45
+t 34 2 46
+u 56 0 47
+v 45 0 48
+w 67 0 49
+x 56 0 50
+y 50 1 51
+z 46 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 84 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 44 0 72
+! 36 0 73
+% 104 0 74
+* 52 0 75
+( 40 0 86 font 21
+) 40 0 87 font 21
+/ 24 2 90 font 21
+hy 45 0 98 font 21
+- "
+em 96 0 97 font 21
+en 52 0 81
+ff 62 2 82
+fi 58 2 83
+fl 60 2 84
+Fi 84 2 85
+Fl 88 2 86
+14 78 2 91
+12 78 2 92
+34 78 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 72 0 13 font 21
+@ 96 0 14 font 21
+bu 72 0 95 font 21
+de 54 2 123
+dg 52 3 124
+dd 46 2 49 font 21
+sc 46 3 42 font 21
+[ 34 0 92 font 21
+] 34 0 93 font 21
++ 96 0 88 font 21
+\- 96 0 89 font 21
+= 96 0 91 font 21
+| 29 0 94 font 21
+sq 72 0 96 font 21
+ru 46 0 99 font 21
+fm 19 2 100 font 21
diff --git a/troff/troff.d/devaps/MB b/troff/troff.d/devaps/MB
new file mode 100644
index 000000000000..1243b76c76d5
--- /dev/null
+++ b/troff/troff.d/devaps/MB
@@ -0,0 +1,139 @@
+#ident "@(#)MB 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Malibu 2 Bold Roman
+name MB
+internalname 18031
+ligatures fi ff fl ffi ffl 0
+charset
+A 81 2 1
+B 65 2 2
+C 74 2 3
+D 83 2 4
+E 63 2 5
+F 58 2 6
+G 80 2 7
+H 80 2 8
+I 38 2 9
+J 37 2 10
+K 74 2 11
+L 60 2 12
+M 98 2 13
+N 83 2 14
+O 85 2 15
+P 62 2 16
+Q 82 2 17
+R 73 2 18
+S 60 2 19
+T 70 2 20
+U 77 2 21
+V 79 2 22
+W 101 2 23
+X 66 2 24
+Y 70 2 25
+Z 64 2 26
+a 51 0 27
+b 60 2 28
+c 45 0 29
+d 60 2 30
+e 51 0 31
+f 37 2 32
+g 54 1 33
+h 64 2 34
+i 35 0 35
+j 33 1 36
+k 60 2 37
+l 35 2 38
+m 91 0 39
+n 62 0 40
+o 55 0 41
+p 60 1 42
+q 61 1 43
+r 41 0 44
+s 44 0 45
+t 35 2 46
+u 62 0 47
+v 59 0 48
+w 85 0 49
+x 53 0 50
+y 59 1 51
+z 52 0 52
+1 50 2 53
+2 50 2 54
+3 50 2 55
+4 50 2 56
+5 50 2 57
+6 50 2 58
+7 50 2 59
+8 50 2 60
+9 50 2 61
+0 50 2 62
+$ 50 0 63
+ct 50 3 64
+& 79 0 65
+: 25 0 66
+; 25 0 67
+. 25 0 68
+, 25 0 69
+` 25 0 70
+' 25 0 71
+? 44 0 72
+! 25 0 73
+% 84 0 74
+* 50 0 75
+( 29 0 76
+) 30 0 77
+/ 55 2 78
+hy 39 0 79
+- "
+em 100 0 80
+ff 72 2 82
+fi 61 2 83
+fl 62 2 84
+Fi 96 2 85
+Fl 96 2 86
+14 88 2 91
+12 88 2 92
+34 88 2 93
+co 82 2 111
+rg 82 2 112
+tm 105 2 113
+# 75 0 116
+@ 103 0 120
+bu 28 0 121
+de 50 2 123
+dg 50 3 124
+dd 49 2 125
+sc 50 3 126
+[ 33 0 127
+] 33 0 128
diff --git a/troff/troff.d/devaps/MI b/troff/troff.d/devaps/MI
new file mode 100644
index 000000000000..8e3f329f6c8e
--- /dev/null
+++ b/troff/troff.d/devaps/MI
@@ -0,0 +1,139 @@
+#ident "@(#)MI 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Malibu 2 Italic
+name MI
+internalname 18021
+ligatures fi ff fl ffi ffl 0
+charset
+A 68 2 1
+B 57 2 2
+C 65 2 3
+D 73 2 4
+E 56 2 5
+F 53 2 6
+G 71 2 7
+H 78 2 8
+I 36 2 9
+J 34 2 10
+K 61 2 11
+L 53 2 12
+M 90 2 13
+N 77 2 14
+O 76 2 15
+P 60 2 16
+Q 78 2 17
+R 64 2 18
+S 49 2 19
+T 60 2 20
+U 75 2 21
+V 68 2 22
+W 86 2 23
+X 66 2 24
+Y 61 2 25
+Z 59 2 26
+a 48 0 27
+b 49 2 28
+c 43 0 29
+d 52 2 30
+e 44 0 31
+f 29 2 32
+g 48 1 33
+h 54 2 34
+i 30 0 35
+j 29 1 36
+k 46 2 37
+l 30 2 38
+m 78 0 39
+n 55 0 40
+o 47 0 41
+p 53 1 42
+q 48 1 43
+r 38 0 44
+s 39 0 45
+t 33 2 46
+u 55 0 47
+v 53 0 48
+w 74 0 49
+x 47 0 50
+y 49 1 51
+z 41 0 52
+1 50 2 53
+2 50 2 54
+3 50 2 55
+4 50 2 56
+5 50 2 57
+6 50 2 58
+7 50 2 59
+8 50 2 60
+9 50 2 61
+0 50 2 62
+$ 50 0 63
+ct 50 3 64
+& 77 0 65
+: 25 0 66
+; 25 0 67
+. 25 0 68
+, 25 0 69
+` 25 0 70
+' 25 0 71
+? 35 0 72
+! 25 0 73
+% 86 0 74
+* 39 0 75
+( 24 0 76
+) 24 0 77
+/ 57 2 78
+hy 39 0 79
+- "
+em 100 0 80
+ff 55 2 82
+fi 54 2 83
+fl 55 2 84
+Fi 78 2 85
+Fl 79 2 86
+14 72 2 91
+12 72 2 92
+34 72 2 93
+co 91 2 111
+rg 91 2 112
+tm 101 2 113
+# 61 0 116
+@ 96 0 120
+bu 28 0 121
+de 41 2 123
+dg 48 3 124
+dd 48 2 125
+sc 48 3 126
+[ 35 0 127
+] 37 0 128
diff --git a/troff/troff.d/devaps/MR b/troff/troff.d/devaps/MR
new file mode 100644
index 000000000000..9f446d6973ef
--- /dev/null
+++ b/troff/troff.d/devaps/MR
@@ -0,0 +1,139 @@
+#ident "@(#)MR 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Malibu 2 Roman
+name MR
+internalname 18011
+ligatures fi ff fl ffi ffl 0
+charset
+A 75 2 1
+B 59 2 2
+C 72 2 3
+D 77 2 4
+E 60 2 5
+F 54 2 6
+G 79 2 7
+H 81 2 8
+I 33 2 9
+J 31 2 10
+K 67 2 11
+L 59 2 12
+M 93 2 13
+N 83 2 14
+O 81 2 15
+P 63 2 16
+Q 79 2 17
+R 66 2 18
+S 58 2 19
+T 62 2 20
+U 77 2 21
+V 71 2 22
+W 97 2 23
+X 63 2 24
+Y 66 2 25
+Z 63 2 26
+a 50 0 27
+b 56 2 28
+c 44 0 29
+d 58 2 30
+e 49 0 31
+f 33 2 32
+g 53 1 33
+h 60 2 34
+i 28 0 35
+j 28 1 36
+k 55 2 37
+l 29 2 38
+m 87 0 39
+n 59 0 40
+o 55 0 41
+p 58 1 42
+q 54 1 43
+r 37 0 44
+s 42 0 45
+t 32 2 46
+u 58 0 47
+v 55 0 48
+w 81 0 49
+x 49 0 50
+y 55 1 51
+z 49 0 52
+1 54 2 53
+2 54 2 54
+3 54 2 55
+4 54 2 56
+5 54 2 57
+6 54 2 58
+7 54 2 59
+8 54 2 60
+9 54 2 61
+0 54 2 62
+$ 54 0 63
+ct 54 3 64
+& 76 0 65
+: 27 0 66
+; 27 0 67
+. 27 0 68
+, 27 0 69
+` 27 0 70
+' 27 0 71
+? 41 0 72
+! 25 0 73
+% 94 0 74
+* 45 0 75
+( 33 0 76
+) 32 0 77
+/ 59 2 78
+hy 37 0 79
+- "
+em 108 0 80
+ff 65 2 82
+fi 58 2 83
+fl 59 2 84
+Fi 91 2 85
+Fl 89 2 86
+14 88 2 91
+12 88 2 92
+34 88 2 93
+co 91 2 111
+rg 91 2 112
+tm 95 2 113
+# 65 0 116
+@ 99 0 120
+bu 28 0 121
+de 50 2 123
+dg 50 3 124
+dd 51 2 125
+sc 51 3 126
+[ 27 0 127
+] 28 0 128
diff --git a/troff/troff.d/devaps/MX b/troff/troff.d/devaps/MX
new file mode 100644
index 000000000000..1b455daedef3
--- /dev/null
+++ b/troff/troff.d/devaps/MX
@@ -0,0 +1,139 @@
+#ident "@(#)MX 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Malibu 2 Bold Italic
+name MX
+internalname 18051
+ligatures fi ff fl ffi ffl 0
+charset
+A 75 2 1
+B 66 2 2
+C 68 2 3
+D 79 2 4
+E 64 2 5
+F 61 2 6
+G 77 2 7
+H 78 2 8
+I 38 2 9
+J 37 2 10
+K 74 2 11
+L 59 2 12
+M 96 2 13
+N 81 2 14
+O 78 2 15
+P 66 2 16
+Q 81 2 17
+R 70 2 18
+S 52 2 19
+T 68 2 20
+U 77 2 21
+V 70 2 22
+W 102 2 23
+X 73 2 24
+Y 62 2 25
+Z 68 2 26
+a 55 0 27
+b 56 2 28
+c 44 0 29
+d 60 2 30
+e 45 0 31
+f 39 2 32
+g 53 1 33
+h 56 2 34
+i 34 0 35
+j 35 1 36
+k 54 2 37
+l 35 2 38
+m 82 0 39
+n 57 0 40
+o 53 0 41
+p 58 1 42
+q 55 1 43
+r 45 0 44
+s 43 0 45
+t 41 2 46
+u 58 0 47
+v 54 0 48
+w 81 0 49
+x 55 0 50
+y 57 1 51
+z 48 0 52
+1 56 2 53
+2 56 2 54
+3 56 2 55
+4 56 2 56
+5 56 2 57
+6 56 2 58
+7 56 2 59
+8 56 2 60
+9 56 2 61
+0 56 2 62
+$ 56 0 63
+ct 56 3 64
+& 83 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 45 0 72
+! 25 0 73
+% 86 0 74
+* 56 0 75
+( 28 0 76
+) 28 0 77
+/ 67 2 78
+hy 44 0 79
+- "
+em 112 0 80
+ff 69 2 82
+fi 63 2 83
+fl 64 2 84
+Fi 92 2 85
+Fl 94 2 86
+14 87 2 91
+12 87 2 92
+34 87 2 93
+co 85 2 111
+rg 84 2 112
+tm 105 2 113
+# 84 0 116
+@ 112 0 120
+bu 28 0 121
+de 55 2 123
+dg 56 3 124
+dd 56 2 125
+sc 56 3 126
+[ 39 0 127
+] 39 0 128
diff --git a/troff/troff.d/devaps/Makefile.mk b/troff/troff.d/devaps/Makefile.mk
new file mode 100644
index 000000000000..92e3d7f1c3fd
--- /dev/null
+++ b/troff/troff.d/devaps/Makefile.mk
@@ -0,0 +1,48 @@
+OBJ = daps.o build.o draw.o getopt.o version.o
+
+FONTS = B I R S CT CW CX GB GI GR GS HI HK HX PO PX S1 SC SM TX DESC \
+ C G H BI CE CI HB HL MB MI MR MX PA PB PI TB
+
+FLAGS = -I. -I.. -DFNTDIR='"$(FNTDIR)"'
+
+.c.o:
+ $(CC) $(CFLAGS) $(WARN) $(CPPFLAGS) $(FLAGS) -c $<
+
+all: daps makedev fonts HM.out
+
+daps: $(OBJ)
+ $(CC) $(LDFLAGS) $(OBJ) $(LIBS) -lm -o daps
+
+makedev: makedev.o
+ $(CC) $(LDFLAGS) makedev.o $(LIBS) -o makedev
+
+fonts: makedev
+ for i in $(FONTS); \
+ do \
+ ./makedev $$i || exit; \
+ done
+
+HM.out: HB.out
+ rm -f $@
+ ln -s HB.out $@
+
+HB.out: fonts
+
+install: all
+ $(INSTALL) -c daps $(ROOT)$(BINDIR)/daps
+ $(STRIP) $(ROOT)$(BINDIR)/daps
+ mkdir -p $(ROOT)$(FNTDIR)/devaps
+ for i in $(FONTS) *.add *.out version; \
+ do \
+ $(INSTALL) -c -m 644 $$i $(ROOT)$(FNTDIR)/devaps/$$i || exit; \
+ done
+
+clean:
+ rm -f $(OBJ) daps makedev.o makedev *.add *.out core log *~
+
+mrproper: clean
+
+build.o: build.c daps.h
+daps.o: daps.c aps.h dev.h daps.h daps.g
+makedev.o: makedev.c dev.h
+draw.o: draw.c ../draw.c
diff --git a/troff/troff.d/devaps/PA b/troff/troff.d/devaps/PA
new file mode 100644
index 000000000000..18125b304a23
--- /dev/null
+++ b/troff/troff.d/devaps/PA
@@ -0,0 +1,139 @@
+#ident "@(#)PA 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Palatino (also Malibu)
+name PA
+internalname 18001
+ligatures fi ff fl ffi ffl 0
+charset
+A 76 2 1
+B 60 2 2
+C 70 2 3
+D 78 2 4
+E 58 2 5
+F 56 2 6
+G 74 2 7
+H 85 2 8
+I 36 2 9
+J 37 2 10
+K 73 2 11
+L 61 2 12
+M 96 2 13
+N 85 2 14
+O 80 2 15
+P 62 2 16
+Q 78 2 17
+R 67 2 18
+S 55 2 19
+T 62 2 20
+U 79 2 21
+V 73 2 22
+W 98 2 23
+X 68 2 24
+Y 68 2 25
+Z 66 2 26
+a 48 0 27
+b 57 2 28
+c 45 0 29
+d 60 2 30
+e 50 0 31
+f 37 2 32
+g 57 1 33
+h 63 2 34
+i 32 0 35
+j 24 1 36
+k 57 2 37
+l 33 2 38
+m 88 0 39
+n 63 0 40
+o 55 0 41
+p 60 1 42
+q 57 1 43
+r 41 0 44
+s 41 0 45
+t 34 2 46
+u 60 0 47
+v 57 0 48
+w 83 0 49
+x 51 0 50
+y 56 1 51
+z 50 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 75 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 43 0 72
+! 26 0 73
+% 75 0 74
+* 52 0 75
+( 34 0 76
+) 34 0 77
+/ 52 2 78
+hy 34 0 79
+- "
+em 104 0 80
+ff 66 2 82
+fi 63 2 83
+fl 63 2 84
+Fi 92 2 85
+Fl 92 2 86
+14 78 2 91
+12 78 2 92
+34 78 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 78 0 116
+@ 104 0 120
+bu 28 0 121
+de 52 2 123
+dg 52 3 124
+dd 52 2 125
+sc 52 3 126
+[ 29 0 127
+] 30 0 128
diff --git a/troff/troff.d/devaps/PB b/troff/troff.d/devaps/PB
new file mode 100644
index 000000000000..8bae7a197ba9
--- /dev/null
+++ b/troff/troff.d/devaps/PB
@@ -0,0 +1,139 @@
+#ident "@(#)PB 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Palatino Bold (also Malibu Bold)
+name PB
+internalname 18041
+ligatures fi ff fl ffi ffl 0
+charset
+A 78 2 1
+B 63 2 2
+C 72 2 3
+D 84 2 4
+E 61 2 5
+F 57 2 6
+G 79 2 7
+H 86 2 8
+I 41 2 9
+J 43 2 10
+K 78 2 11
+L 63 2 12
+M 102 2 13
+N 85 2 14
+O 84 2 15
+P 63 2 16
+Q 84 2 17
+R 74 2 18
+S 58 2 19
+T 67 2 20
+U 79 2 21
+V 79 2 22
+W 101 2 23
+X 68 2 24
+Y 69 2 25
+Z 65 2 26
+a 50 0 27
+b 61 2 28
+c 46 0 29
+d 61 2 30
+e 50 0 31
+f 41 2 32
+g 56 1 33
+h 63 2 34
+i 35 0 35
+j 32 1 36
+k 63 2 37
+l 35 2 38
+m 91 0 39
+n 63 0 40
+o 57 0 41
+p 61 1 42
+q 61 1 43
+r 42 0 44
+s 43 0 45
+t 37 2 46
+u 61 0 47
+v 59 0 48
+w 85 0 49
+x 52 0 50
+y 59 1 51
+z 50 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 80 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 49 0 72
+! 26 0 73
+% 78 0 74
+* 52 0 75
+( 34 0 76
+) 34 0 77
+/ 52 2 78
+hy 40 0 79
+- "
+em 104 0 80
+ff 77 2 82
+fi 71 2 83
+fl 71 2 84
+Fi 105 2 85
+Fl 105 2 86
+14 78 2 91
+12 78 2 92
+34 78 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 75 0 116
+@ 101 0 120
+bu 28 0 121
+de 39 2 123
+dg 50 3 124
+dd 50 2 125
+sc 50 3 126
+[ 25 0 127
+] 25 0 128
diff --git a/troff/troff.d/devaps/PI b/troff/troff.d/devaps/PI
new file mode 100644
index 000000000000..551ca7f306ab
--- /dev/null
+++ b/troff/troff.d/devaps/PI
@@ -0,0 +1,139 @@
+#ident "@(#)PI 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Palatino Italic (also Malibu Italic)
+name PI
+internalname 18081
+ligatures fi ff fl ffi ffl 0
+charset
+A 72 2 1
+B 58 2 2
+C 63 2 3
+D 74 2 4
+E 55 2 5
+F 56 2 6
+G 68 2 7
+H 79 2 8
+I 35 2 9
+J 37 2 10
+K 68 2 11
+L 54 2 12
+M 99 2 13
+N 80 2 14
+O 75 2 15
+P 59 2 16
+Q 74 2 17
+R 65 2 18
+S 50 2 19
+T 60 2 20
+U 77 2 21
+V 71 2 22
+W 93 2 23
+X 72 2 24
+Y 69 2 25
+Z 63 2 26
+a 47 0 27
+b 43 2 28
+c 42 0 29
+d 52 2 30
+e 42 0 31
+f 34 2 32
+g 49 1 33
+h 52 2 34
+i 25 0 35
+j 30 1 36
+k 49 2 37
+l 29 2 38
+m 77 0 39
+n 54 0 40
+o 46 0 41
+p 51 1 42
+q 46 1 43
+r 38 0 44
+s 37 0 45
+t 34 2 46
+u 52 0 47
+v 51 0 48
+w 72 0 49
+x 49 0 50
+y 52 1 51
+z 45 0 52
+1 50 2 53
+2 50 2 54
+3 50 2 55
+4 50 2 56
+5 50 2 57
+6 50 2 58
+7 50 2 59
+8 50 2 60
+9 50 2 61
+0 50 2 62
+$ 50 0 63
+ct 50 3 64
+& 75 0 65
+: 25 0 66
+; 25 0 67
+. 25 0 68
+, 25 0 69
+` 25 0 70
+' 25 0 71
+? 40 0 72
+! 25 0 73
+% 75 0 74
+* 55 0 75
+( 34 0 76
+) 34 0 77
+/ 50 2 78
+hy 38 0 79
+- "
+em 100 0 80
+ff 57 2 82
+fi 54 2 83
+fl 57 2 84
+Fi 78 2 85
+Fl 80 2 86
+14 75 2 91
+12 75 2 92
+34 75 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 75 0 116
+@ 100 0 120
+bu 28 0 121
+de 50 2 123
+dg 50 3 124
+dd 50 2 125
+sc 50 3 126
+[ 34 0 127
+] 34 0 128
diff --git a/troff/troff.d/devaps/PO b/troff/troff.d/devaps/PO
new file mode 100644
index 000000000000..9d18dd009e43
--- /dev/null
+++ b/troff/troff.d/devaps/PO
@@ -0,0 +1,147 @@
+#ident "@(#)PO 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Constant Width (also CW)
+name PO
+internalname 10941
+spacewidth 68
+max_range 2
+charset
+A 68 2 1
+B 68 2 2
+C 68 2 3
+D 68 2 4
+E 68 2 5
+F 68 2 6
+G 68 2 7
+H 68 2 8
+I 68 2 9
+J 68 2 10
+K 68 2 11
+L 68 2 12
+M 68 2 13
+N 68 2 14
+O 68 2 15
+P 68 2 16
+Q 68 2 17
+R 68 2 18
+S 68 2 19
+T 68 2 20
+U 68 2 21
+V 68 2 22
+W 68 2 23
+X 68 2 24
+Y 68 2 25
+Z 68 2 26
+a 68 0 27
+b 68 2 28
+c 68 0 29
+d 68 2 30
+e 68 0 31
+f 68 2 32
+g 68 1 33
+h 68 2 34
+i 68 0 35
+j 68 1 36
+k 68 2 37
+l 68 2 38
+m 68 0 39
+n 68 0 40
+o 68 0 41
+p 68 1 42
+q 68 1 43
+r 68 0 44
+s 68 0 45
+t 68 2 46
+u 68 0 47
+v 68 0 48
+w 68 0 49
+x 68 0 50
+y 68 1 51
+z 68 0 52
+1 68 2 53
+2 68 2 54
+3 68 2 55
+4 68 2 56
+5 68 2 57
+6 68 2 58
+7 68 2 59
+8 68 2 60
+9 68 2 61
+0 68 2 62
+$ 68 0 63
+ct 68 3 64
+& 68 0 65
+: 68 0 66
+; 68 0 67
+. 68 0 68
+, 68 0 69
+` 68 0 70
+' 68 0 71
+? 68 0 72
+! 68 0 73
+% 68 0 74
+* 68 0 75
+( 68 0 76
+) 68 0 77
+/ 68 2 78
+sl "
+hy 68 0 79
+- "
+= 68 0 80
++ 68 0 81
+no 68 0 82
+< 68 0 83
+> 68 0 84
+{ 68 0 85
+} 68 0 86
+^ 68 0 91
+~ 68 0 92
+" 68 0 93
+fm 68 2 94
+_ 68 0 109
+ul "
+| 68 0 110
+or "
+lh 68 2 111
+\ 68 0 112
+# 68 0 116
+@ 68 0 120
+sq 68 0 121
+-> 68 0 122
+<- 68 0 123
+dg 68 3 124
+ua 68 3 125
+da 68 3 126
+[ 68 0 127
+] 68 0 128
diff --git a/troff/troff.d/devaps/PX b/troff/troff.d/devaps/PX
new file mode 100644
index 000000000000..3a285dac59dc
--- /dev/null
+++ b/troff/troff.d/devaps/PX
@@ -0,0 +1,140 @@
+#ident "@(#)PX 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Palatino Bold Italic
+name PX
+internalname 18041
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+charset
+A 78 2 1
+B 63 2 2
+C 72 2 3
+D 84 2 4
+E 61 2 5
+F 57 2 6
+G 79 2 7
+H 86 2 8
+I 41 2 9
+J 43 2 10
+K 78 2 11
+L 63 2 12
+M 102 2 13
+N 85 2 14
+O 84 2 15
+P 63 2 16
+Q 84 2 17
+R 74 2 18
+S 58 2 19
+T 67 2 20
+U 79 2 21
+V 79 2 22
+W 101 2 23
+X 68 2 24
+Y 69 2 25
+Z 65 2 26
+a 50 0 27
+b 61 2 28
+c 46 0 29
+d 61 2 30
+e 50 0 31
+f 41 2 32
+g 56 1 33
+h 63 2 34
+i 35 0 35
+j 32 1 36
+k 63 2 37
+l 35 2 38
+m 91 0 39
+n 63 0 40
+o 57 0 41
+p 61 1 42
+q 61 1 43
+r 42 0 44
+s 43 0 45
+t 37 2 46
+u 61 0 47
+v 59 0 48
+w 85 0 49
+x 52 0 50
+y 59 1 51
+z 50 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 80 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 49 0 72
+! 26 0 73
+% 78 0 74
+* 52 0 75
+( 34 0 76
+) 34 0 77
+/ 52 2 78
+hy 40 0 79
+- "
+em 104 0 80
+ff 77 2 82
+fi 71 2 83
+fl 71 2 84
+Fi 105 2 85
+Fl 105 2 86
+14 78 2 91
+12 78 2 92
+34 78 2 93
+co 50 2 111 slant 0
+rg 50 2 112 slant 0
+tm 50 2 113 slant 0
+# 75 0 116
+@ 101 0 120
+bu 28 0 121 slant 0
+de 39 2 123 slant 0
+dg 50 3 124
+dd 50 2 125
+sc 50 3 126
+[ 25 0 127
+] 25 0 128
diff --git a/troff/troff.d/devaps/R b/troff/troff.d/devaps/R
new file mode 100644
index 000000000000..2a674f18c691
--- /dev/null
+++ b/troff/troff.d/devaps/R
@@ -0,0 +1,148 @@
+#ident "@(#)R 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Times Roman (with 15 characters from new disk)
+name R
+internalname 29201
+alternate_font
+ligatures fi ff fl ffi ffl 0
+charset
+A 77 2 1
+B 67 2 2
+C 73 2 3
+D 77 2 4
+E 67 2 5
+F 63 2 6
+G 78 2 7
+H 83 2 8
+I 40 2 9
+J 48 2 10
+K 77 2 11
+L 67 2 12
+M 99 2 13
+N 85 2 14
+O 77 2 15
+P 61 2 16
+Q 77 2 17
+R 76 2 18
+S 60 2 19
+T 67 2 20
+U 80 2 21
+V 73 2 22
+W 103 2 23
+X 78 2 24
+Y 78 2 25
+Z 71 2 26
+a 50 0 27
+b 53 2 28
+c 45 0 29
+d 53 2 30
+e 45 0 31
+f 35 2 32
+g 51 1 33
+h 54 2 34
+i 28 0 35
+j 30 1 36
+k 52 2 37
+l 28 2 38
+m 82 0 39
+n 53 0 40
+o 48 0 41
+p 52 1 42
+q 52 1 43
+r 39 0 44
+s 38 0 45
+t 34 2 46
+u 54 0 47
+v 46 0 48
+w 70 0 49
+x 50 0 50
+y 50 1 51
+z 46 0 52
+1 52 2 53
+2 52 2 54
+3 52 2 55
+4 52 2 56
+5 52 2 57
+6 52 2 58
+7 52 2 59
+8 52 2 60
+9 52 2 61
+0 52 2 62
+$ 52 0 63
+ct 52 3 64
+& 90 0 65
+: 26 0 66
+; 26 0 67
+. 26 0 68
+, 26 0 69
+` 26 0 70
+' 26 0 71
+? 52 0 72
+! 26 0 73
+% 78 0 74
+* 52 0 75
+( 43 0 71 font 21
+) 43 0 72 font 21
+/ 46 2 75 font 21
+hy 35 0 83 font 21
+- "
+em 96 0 82 font 21
+en 52 0 81
+ff 63 2 82
+fi 55 2 83
+fl 55 2 84
+Fi 82 2 85
+Fl 82 2 86
+14 78 2 91
+12 78 2 92
+34 78 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 72 0 13 font 21
+@ 96 0 14 font 21
+bu 72 0 80 font 21
+de 54 2 123
+dg 52 3 124
+dd 46 2 49 font 21
+sc 46 3 42 font 21
+[ 37 0 77 font 21
+] 37 0 78 font 21
++ 77 0 73 font 21
+\- 77 0 74 font 21
+= 77 0 76 font 21
+| 10 0 79 font 21
+sq 72 0 81 font 21
+ru 42 0 84 font 21
+fm 21 2 85 font 21
diff --git a/troff/troff.d/devaps/README b/troff/troff.d/devaps/README
new file mode 100644
index 000000000000..257e0bed6c02
--- /dev/null
+++ b/troff/troff.d/devaps/README
@@ -0,0 +1,102 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#ident "@(#)README 1.4 05/06/08 SMI"
+#
+# Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+
+This directory contains the ASCII font and device tables and a
+postprocessor for an APS-5 phototypesetter. The device independent troff uses
+the information contained in these files, but instead of looking at the
+ASCII files, troff reads an equivalent set of binary tables that are
+produced by a program called 'makedev'.
+
+ Since you need to be a little careful when you run makedev, we
+have written a small shell program called 'maketables' that takes one
+or more of the ASCII files as input, and then properly updates all the
+required binary files. For example, to make a complete new set of
+binary tables just type in the command,
+
+ maketables *
+
+On the other hand if just a few font files have been changed, eg. R,
+I, and PA, the command line,
+
+ maketables R I PA
+
+will remake all the required binary files. In neither of the above
+examples could you simply substitute makedev for maketables and have
+things work properly. After you've run either maketables or makedev
+the binary files are easy to find - their names all end in the suffix
+'.out' or '.add'. maketables uses the makedev defined by its shell
+variable MAKEDEV.
+
+The shell program 'maketables' is located in the parent of this directory.
+
+N.B. The contents of this directory (the ASCII font description
+tables, the postprocessor daps, and the description table compiler
+makedev) are all tailored for the particular font disk used in the
+Murray Hill Computing Center. Any installation with a different
+APS font set will almost certainly have to hand-tune some of the
+font description files and will possibly want to use the more general
+makedev located in the parent of this directory.
+
+
+-------------------------------------------------------------------------------
+
+Changes since the original release:
+
+
+ 1: The width of ru on the R, I, B, and S fonts is 12 units less than
+ Autologic's specifications. This eliminates the dashed line problems
+ we were having, provided only troff reads these tables.
+
+ 2: Added the en character to the I and B fonts so that font positions
+ 1, 2, and 3 would all be the same size. Told users on other systems
+ to remove en from R since it's only used in our banners and that
+ seemed to be a less error prone process.
+
+ 3: Added xe, xt, and xk to DESC, GB, and GR files.
+
+ 4: Set the character code for bs in the S font to 0 so that the old
+ Bell System logo will be replaced by white space on the APS-5.
+
+ 5: Added the new ATT logo characters to DESC and the S font file.
+ LH and LV are logos in horizontal and vertical configurations,
+ respectively.
+
+ 6: Fixed (probably overdid) the ascender/descender stuff.
+
+ 7: Added the old Bell Logo to the DESC file and the S font as character
+ LB. Still have \(bs replaced by white space.
+
+
+-------------------------------------------------------------------------------
diff --git a/troff/troff.d/devaps/S b/troff/troff.d/devaps/S
new file mode 100644
index 000000000000..e236f2c4f08a
--- /dev/null
+++ b/troff/troff.d/devaps/S
@@ -0,0 +1,127 @@
+#ident "@(#)S 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+name S
+internalname 21
+special
+alternate_font
+max_range 3
+charset
+" 35 0 1
+dq "
+\' 27 2 2
+aa "
+\ 37 0 3
+rs "
+^ 40 0 4
+ul 45 1 5 max_range 2
+_ "
+\` 27 2 6
+ga "
+~ 40 0 7
+/ 37 2 8
+sl "
+< 96 0 9
+> 96 0 10
+{ 37 0 11
+} 37 0 12
+# 72 0 13
+@ 96 0 14
+pl 72 0 15
++ "
+mi 72 0 16
+\- "
+eq 72 0 17
+= "
+** 43 0 18
+sr 81 3 19
+rn 48 2 20
+<= 96 2 21
+>= 96 2 22
+== 96 0 23
+ap 96 0 24
+~= 96 0 25
+!= 96 2 26
+-> 96 0 27
+<- 96 0 28
+ua 48 3 29
+da 48 3 30
+mu 72 0 31
+di 72 0 32
++- 96 0 33
+cu 96 2 34
+ca 96 2 35
+sb 96 2 36
+sp 96 2 37
+ib 96 3 38
+ip 96 3 39
+if 91 0 40
+pd 56 2 41
+sc 46 3 42
+gr 96 2 43
+no 59 0 44
+is 64 3 45
+pt 72 0 46
+es 74 2 47
+mo 72 2 48
+dd 46 2 49
+rh 126 2 50
+lh 128 2 51
+or 24 2 53
+ci 85 2 54
+| 0 0 66
+br "
+ts 48 0 67
+*U 75 2 68
+*Q 85 2 69
+*W 96 2 70
+bu 72 0 80
+sq 72 0 81
+bx 72 0 111
+em 96 0 82
+ru 42 0 84
+fm 21 2 85
+Sl 55 2 116 max_range 2
+bv 50 3 21 font 11
+lt 50 3 15 font 11
+lb 50 3 16 font 11
+rt 50 3 17 font 11
+rb 50 3 18 font 11
+lk 50 3 19 font 11
+rk 50 3 20 font 11
+lf 50 3 22 font 11
+rf 50 3 23 font 11
+lc 50 3 24 font 11
+rc 50 3 25 font 11
+LH 212 3 0 font 441
+LV 112 3 0 font 441
diff --git a/troff/troff.d/devaps/S1 b/troff/troff.d/devaps/S1
new file mode 100644
index 000000000000..99b9dc6e01f2
--- /dev/null
+++ b/troff/troff.d/devaps/S1
@@ -0,0 +1,74 @@
+#ident "@(#)S1 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+name S1
+internalname 32051
+special
+max_range 2
+charset
+-+ 100 0 7
+!< 100 2 12
+!> 100 2 13
+le 100 2 14
+ge 100 2 15
+el 100 2 16
+eg 100 2 17
+LE 100 2 18
+GE 100 2 19
+EL 100 2 20
+EG 100 2 21
+<> 100 3 28
+>< 100 3 29
+as 100 2 30
+os 100 2 31
+RC 100 2 43
+TR 100 2 45
+RB 100 0 47
+CB 100 2 48
+=. 100 0 50
+=: 100 0 52
+gp 100 0 53
+=p 100 0 54
+4d 75 0 55
+tf 100 2 57
+bc 100 2 59
+an 50 2 65
+ra 50 2 66
+pp 100 2 67
+cy 100 0 68
+de 50 2 71
+ps 50 2 76
+rd 50 0 81
+ld 50 0 83
+vs 68 0 121 font 10941
+cs 68 2 124 font 10941
diff --git a/troff/troff.d/devaps/SC b/troff/troff.d/devaps/SC
new file mode 100644
index 000000000000..f55ac5a65b1e
--- /dev/null
+++ b/troff/troff.d/devaps/SC
@@ -0,0 +1,135 @@
+#ident "@(#)SC 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Script
+name SC
+internalname 31
+alternate_font
+max_range 2
+charset
+A 81 2 1
+B 91 2 2
+C 82 2 3
+D 88 2 4
+E 62 2 5
+F 75 2 6
+G 84 2 7
+H 87 2 8
+I 66 2 9
+J 55 2 10
+K 86 2 11
+L 78 2 12
+M 100 2 13
+N 87 2 14
+O 60 2 15
+P 74 2 16
+Q 67 2 17
+R 87 2 18
+S 78 2 19
+T 69 2 20
+U 91 2 21
+V 65 2 22
+W 90 2 23
+X 78 2 24
+Y 81 2 25
+Z 84 2 26
+a 36 0 27
+b 30 2 28
+c 24 0 29
+d 36 2 30
+e 26 0 31
+f 28 2 32
+g 34 1 33
+h 39 2 34
+i 22 0 35
+j 23 1 36
+k 35 2 37
+l 22 2 38
+m 62 0 39
+n 44 0 40
+o 26 0 41
+p 40 1 42
+q 36 1 43
+r 30 0 44
+s 23 0 45
+t 23 2 46
+u 36 0 47
+v 38 0 48
+w 46 0 49
+x 33 0 50
+y 44 1 51
+z 36 0 52
+1 52 2 53 font 6041
+2 52 2 54 font 6041
+3 52 2 55 font 6041
+4 52 2 56 font 6041
+5 52 2 57 font 6041
+6 52 2 58 font 6041
+7 52 2 59 font 6041
+8 52 2 60 font 6041
+9 52 2 61 font 6041
+0 52 2 62 font 6041
+$ 52 0 63 font 6041
+ct 52 3 64 font 6041
+& 75 0 65 font 18081
+: 26 0 66 font 6041
+; 26 0 67 font 6041
+. 26 0 68 font 6041
+, 26 0 69 font 6041
+` 26 0 70 font 6041
+' 26 0 71 font 6041
+? 52 0 72 font 6041
+! 32 0 73 font 6041
+% 104 0 74 font 6041
+* 52 0 75 font 6041
+( 52 0 76 font 6041
+) 52 0 77 font 6041
+/ 52 2 78 font 6041
+hy 40 0 79 font 6041
+- "
+em 104 0 80 font 6041
+14 104 2 91 font 6041
+12 104 2 92 font 6041
+34 104 2 93 font 6041
+co 64 2 111 font 6041
+rg 64 2 112 font 6041
+tm 64 2 113 font 6041
+# 52 0 116 font 6041
+@ 104 0 120 font 6041
+bu 28 0 121 font 6041
+de 52 2 123 font 6041
+dg 52 3 124 font 6041
+dd 52 2 125 font 6041
+sc 52 3 126 font 6041
+[ 52 0 127 font 6041
+] 52 0 128 font 6041
diff --git a/troff/troff.d/devaps/SM b/troff/troff.d/devaps/SM
new file mode 100644
index 000000000000..c989a8edb5bf
--- /dev/null
+++ b/troff/troff.d/devaps/SM
@@ -0,0 +1,134 @@
+#ident "@(#)SM 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Stymie Medium
+name SM
+internalname 25681
+max_range 2
+charset
+A 77 2 1
+B 64 2 2
+C 77 2 3
+D 74 2 4
+E 60 2 5
+F 56 2 6
+G 82 2 7
+H 78 2 8
+I 36 2 9
+J 37 2 10
+K 73 2 11
+L 59 2 12
+M 89 2 13
+N 73 2 14
+O 85 2 15
+P 61 2 16
+Q 86 2 17
+R 64 2 18
+S 57 2 19
+T 60 2 20
+U 79 2 21
+V 71 2 22
+W 104 2 23
+X 67 2 24
+Y 66 2 25
+Z 56 2 26
+a 52 0 27
+b 60 2 28
+c 51 0 29
+d 60 2 30
+e 52 0 31
+f 32 2 32
+g 58 1 33
+h 59 2 34
+i 31 0 35
+j 30 1 36
+k 55 2 37
+l 31 2 38
+m 82 0 39
+n 58 0 40
+o 52 0 41
+p 60 1 42
+q 60 1 43
+r 39 0 44
+s 42 0 45
+t 28 2 46
+u 58 0 47
+v 51 0 48
+w 74 0 49
+x 53 0 50
+y 52 1 51
+z 42 0 52
+1 56 2 53
+2 56 2 54
+3 56 2 55
+4 56 2 56
+5 56 2 57
+6 56 2 58
+7 56 2 59
+8 56 2 60
+9 56 2 61
+0 56 2 62
+$ 56 0 63
+ct 56 3 64
+& 68 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 56 0 72
+! 28 0 73
+% 112 0 74
+* 52 0 75
+( 29 0 76
+) 29 0 77
+/ 52 2 78
+hy 35 0 79
+- "
+em 112 0 80
+14 112 2 91
+12 112 2 92
+34 112 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 75 0 116
+@ 113 0 120
+bu 28 0 121
+de 57 2 123
+dg 57 3 124
+dd 58 2 125
+sc 57 3 126
+[ 23 0 127
+] 23 0 128
diff --git a/troff/troff.d/devaps/TB b/troff/troff.d/devaps/TB
new file mode 100644
index 000000000000..7d7afe5529db
--- /dev/null
+++ b/troff/troff.d/devaps/TB
@@ -0,0 +1,139 @@
+#ident "@(#)TB 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Techno Bold (also Futura Demi-Bold, Utica Demi-Bold)
+name TB
+internalname 27201
+ligatures fi ff fl ffi ffl 0
+charset
+A 66 2 1
+B 55 2 2
+C 61 2 3
+D 61 2 4
+E 48 2 5
+F 45 2 6
+G 72 2 7
+H 67 2 8
+I 26 2 9
+J 44 2 10
+K 60 2 11
+L 38 2 12
+M 83 2 13
+N 71 2 14
+O 72 2 15
+P 52 2 16
+Q 72 2 17
+R 55 2 18
+S 50 2 19
+T 50 2 20
+U 66 2 21
+V 65 2 22
+W 88 2 23
+X 66 2 24
+Y 60 2 25
+Z 57 2 26
+a 55 0 27
+b 55 2 28
+c 39 0 29
+d 57 2 30
+e 50 0 31
+f 33 2 32
+g 56 1 33
+h 56 2 34
+i 24 0 35
+j 24 1 36
+k 49 2 37
+l 24 2 38
+m 83 0 39
+n 56 0 40
+o 49 0 41
+p 55 1 42
+q 55 1 43
+r 32 0 44
+s 38 0 45
+t 33 2 46
+u 57 0 47
+v 48 0 48
+w 83 0 49
+x 50 0 50
+y 48 1 51
+z 44 0 52
+1 55 2 53
+2 55 2 54
+3 55 2 55
+4 55 2 56
+5 55 2 57
+6 55 2 58
+7 55 2 59
+8 55 2 60
+9 55 2 61
+0 55 2 62
+$ 55 0 63
+ct 55 3 64
+& 82 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 55 0 72
+! 28 0 73
+% 90 0 74
+* 55 0 75
+( 25 0 76
+) 25 0 77
+/ 55 2 78
+hy 32 0 79
+- "
+em 110 0 80
+ff 61 2 82
+fi 56 2 83
+fl 56 2 84
+Fi 84 2 85
+Fl 84 2 86
+14 83 2 91
+12 83 2 92
+34 83 2 93
+co 50 2 111
+rg 50 2 112
+tm 50 2 113
+# 82 0 116
+@ 110 0 120
+bu 28 0 121
+de 55 2 123
+dg 55 3 124
+dd 55 2 125
+sc 55 3 126
+[ 24 0 127
+] 24 0 128
diff --git a/troff/troff.d/devaps/TX b/troff/troff.d/devaps/TX
new file mode 100644
index 000000000000..183e105b6f5d
--- /dev/null
+++ b/troff/troff.d/devaps/TX
@@ -0,0 +1,140 @@
+#ident "@(#)TX 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+# Techno Bold Italic
+name TX
+internalname 27201
+ligatures fi ff fl ffi ffl 0
+default_slant 14
+charset
+A 66 2 1
+B 55 2 2
+C 61 2 3
+D 61 2 4
+E 48 2 5
+F 45 2 6
+G 72 2 7
+H 67 2 8
+I 26 2 9
+J 44 2 10
+K 60 2 11
+L 38 2 12
+M 83 2 13
+N 71 2 14
+O 72 2 15
+P 52 2 16
+Q 72 2 17
+R 55 2 18
+S 50 2 19
+T 50 2 20
+U 66 2 21
+V 65 2 22
+W 88 2 23
+X 66 2 24
+Y 60 2 25
+Z 57 2 26
+a 55 0 27
+b 55 2 28
+c 39 0 29
+d 57 2 30
+e 50 0 31
+f 33 2 32
+g 56 1 33
+h 56 2 34
+i 24 0 35
+j 24 1 36
+k 49 2 37
+l 24 2 38
+m 83 0 39
+n 56 0 40
+o 49 0 41
+p 55 1 42
+q 55 1 43
+r 32 0 44
+s 38 0 45
+t 33 2 46
+u 57 0 47
+v 48 0 48
+w 83 0 49
+x 50 0 50
+y 48 1 51
+z 44 0 52
+1 55 2 53
+2 55 2 54
+3 55 2 55
+4 55 2 56
+5 55 2 57
+6 55 2 58
+7 55 2 59
+8 55 2 60
+9 55 2 61
+0 55 2 62
+$ 55 0 63
+ct 55 3 64
+& 82 0 65
+: 28 0 66
+; 28 0 67
+. 28 0 68
+, 28 0 69
+` 28 0 70
+' 28 0 71
+? 55 0 72
+! 28 0 73
+% 90 0 74
+* 55 0 75
+( 25 0 76
+) 25 0 77
+/ 55 2 78
+hy 32 0 79
+- "
+em 110 0 80
+ff 61 2 82
+fi 56 2 83
+fl 56 2 84
+Fi 84 2 85
+Fl 84 2 86
+14 83 2 91
+12 83 2 92
+34 83 2 93
+co 50 2 111 slant 0
+rg 50 2 112 slant 0
+tm 50 2 113 slant 0
+# 82 0 116
+@ 110 0 120
+bu 28 0 121 slant 0
+de 55 2 123 slant 0
+dg 55 3 124
+dd 55 2 125
+sc 55 3 126
+[ 24 0 127
+] 24 0 128
diff --git a/troff/troff.d/devaps/aps.h b/troff/troff.d/devaps/aps.h
new file mode 100644
index 000000000000..ead47bd3052f
--- /dev/null
+++ b/troff/troff.d/devaps/aps.h
@@ -0,0 +1,136 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "aps.h 1.6 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)aps.h 1.3 (gritter) 8/9/05
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+#define APSNOOP 00
+#define HSP25U 0201
+#define HSP400U 0202
+#define HSP200U 0203
+#define HSP100U 0204
+#define HSP50U 0205
+#define HSP72P 0206
+#define HSP36P 0207
+#define HSP18P 0210
+#define HSP9P 0211
+#define HSP45P 0212
+#define MARKLOC 0217
+#define RTNMARK 0220
+#define DRAW 0221
+#define RTNMARKX 0222
+#define RTNMARKY 0223
+#define SPEED 0240
+#define DCLMSZ 0241
+#define SETOBLIQUE 0242
+#define WRREAD 0243
+#define LFTMGN 0244
+#define RETRACE 0245
+#define UPDOWN 0246
+#define DISPFONT 0257
+#define FONT 0260
+#define HSIZE 0261
+#define VSIZE 0262
+#define HVSIZE 0263
+#define REPEAT 0264
+#define SAVSTR 0265
+#define EXSTR 0266
+#define SETCTR 0267
+#define SETPTR 0270
+#define STRTJOB 0272
+#define STRTPG 0273
+#define SELFSCAN 0274
+#define VSSPOTS 0276
+#define HSSPOTS 0277
+#define VSPABS 0300
+#define VSPREL 0301
+#define HSPABS 0302
+#define HSPREL 0303
+#define LTRSP 0304
+#define LTRSPREL 0305
+#define PGLEAD 0313
+#define HPSNABS 0315
+#define VPSNABS 0316
+#define SKIP 0317
+#define STORVERT 0320
+#define STORVTSPOT 0321
+#define SETTAB 0323
+#define STRVRA 0325
+#define STRHRA 0326
+#define STRVRB 0327
+#define STRHRB 0330
+#define STORHSPA 0332
+#define STORHSPB 0333
+#define STORHSPC 0334
+#define STORHSPD 0335
+#define MKH 0336
+#define RTNHMK 0337
+#define EXVSP 0340
+#define RTN 0341
+#define CRTN 0342
+#define XTAB 0343
+#define XTABCR 0344
+#define XRULA 0345
+#define XRULATAB 0346
+#define XRULB 0347
+#define XNORMAL 0350
+#define XOBLIQUE 0351
+#define XHSPA 0352
+#define XHSPB 0353
+#define XHSPC 0354
+#define XHSPD 0355
+#define RESET 0356
+#define DISPFNTS 0357
+#define ENDSTR 0360
+#define DECCTR 0361
+#define MKV 0362
+#define RTNVMK 0363
+#define ESCGRAPHICS 0366
+#define CUT 0374
+#define HALT 0375
+#define ENDJOB 0376
+
+#define MAXESCAPE 8400
+#define MAXLEAD 32367
diff --git a/troff/troff.d/devaps/build.c b/troff/troff.d/devaps/build.c
new file mode 100644
index 000000000000..ecefacc6db59
--- /dev/null
+++ b/troff/troff.d/devaps/build.c
@@ -0,0 +1,323 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "build.c 1.5 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)build.c 1.4 (gritter) 8/13/05
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+#include <stdio.h>
+
+#include "daps.h"
+
+#define LIBDIR "charlib" /* files found in *fontdir/LIBDIR */
+
+
+/*
+ *
+ * These variables are used to save and later restore the post-processor's
+ * environment.
+ *
+ */
+
+
+int ohpos;
+int ovpos;
+int ofont;
+int osize;
+
+int env = 0; /* nonzero if environment is saved */
+
+
+extern int hpos;
+extern int vpos;
+extern int font;
+extern int size;
+
+extern char *fontdir;
+#define devname troff_devname
+extern char devname[];
+extern FILE *tf;
+
+#define oput(n) putc(n, tf)
+
+
+/*****************************************************************************/
+
+
+int
+newfile(
+
+
+ char *name, /* start reading from this file */
+ int size /* may use it to get the file */
+)
+
+{
+
+
+ FILE *fp;
+
+
+ /********************************************************************
+ * *
+ * Used when we want to take the post-processor's input from *
+ * a different file for a while. Added to handle problems with the *
+ * new logos, but it could easily be used to define other special *
+ * characters. *
+ * *
+ ********************************************************************/
+
+
+ if ( env || (fp = charfile(name, size)) == NULL )
+ return(1);
+
+ save_env();
+ nconv(fp);
+ restore_env();
+ fclose(fp);
+
+ return(0);
+
+} /* End of newfile */
+
+
+/*****************************************************************************/
+
+
+FILE *charfile(
+
+
+ char *name, /* start reading from this file */
+ int size /* size of the character to print */
+)
+
+
+{
+
+
+ char path[100]; /* file pathname put here */
+ FILE *fp; /* file pointer for *path */
+
+
+ /********************************************************************
+ * *
+ * First tries to open file *name.size in the right directory, *
+ * and if it can't then it tries *name. Returns the file pointer *
+ * or NULL if either file can't be opened. *
+ * *
+ ********************************************************************/
+
+
+ sprintf(path, "%s/dev%s/%s/%s.%d", fontdir, devname, LIBDIR, name, size);
+
+ if ( (fp = fopen(path, "r")) == NULL ) {
+ sprintf(path, "%s/dev%s/%s/%s", fontdir, devname, LIBDIR, name);
+ fp = fopen(path, "r");
+ } /* End if */
+
+ return(fp);
+
+} /* End of charfile */
+
+
+/*****************************************************************************/
+
+void
+save_env(void)
+
+
+{
+
+
+ /********************************************************************
+ * *
+ * Before we start reading from a different file we'll want *
+ * to save the values of the variables that will be needed to get *
+ * back to where we were. *
+ * *
+ ********************************************************************/
+
+
+ hflush();
+
+ ohpos = hpos;
+ ovpos = vpos;
+ ofont = font;
+ osize = size;
+
+ env = 1;
+
+} /* End of save_env */
+
+
+/*****************************************************************************/
+
+
+void
+restore_env(void)
+
+
+{
+
+
+ /********************************************************************
+ * *
+ * Hopefully does everything needed to get the post-processor *
+ * back to where it was before the input was diverted. *
+ * *
+ ********************************************************************/
+
+
+ hgoto(ohpos);
+ vgoto(ovpos);
+
+ setfont(ofont);
+ setsize(osize);
+
+ env = 0;
+
+} /* End of restore_env */
+
+
+/*****************************************************************************/
+
+
+void
+nconv(
+
+
+ FILE *fp /* new file we're reading from */
+)
+
+
+{
+
+
+ int ch; /* first character of the command */
+ int c, n; /* used in reading chars from *fp */
+ char str[100]; /* don't really need this much room */
+
+
+ /********************************************************************
+ * *
+ * A restricted and slightly modified version of the conv() *
+ * routine found in all of troff's post-processors. It should only *
+ * be used to interpret the special character building files found *
+ * in directory *fontdir/LIBDIR. *
+ * *
+ ********************************************************************/
+
+
+ while ( (ch = getc(fp)) != EOF ) {
+
+ switch ( ch ) {
+
+ case 'w': /* just ignore these guys */
+ case ' ':
+ case '\n':
+ case 0:
+ break;
+
+ case 'c': /* single ASCII character */
+ put1(getc(fp));
+ break;
+
+ case 'C': /* special character */
+ fscanf(fp, "%s", str);
+ put1s(str);
+ break;
+
+ case 'h': /* relative horizontal motion */
+ fscanf(fp, "%d", &n);
+ hmot(n);
+ break;
+
+ case 'v':
+ fscanf(fp, "%d", &n);
+ vmot(n);
+ break;
+
+ case 'x': /* device control - font change only */
+ fscanf(fp, "%s", str);
+ if ( str[0] == 'f' ) {
+ fscanf(fp, "%d %s", &n, str);
+ loadfont(n, str, "");
+ } /* End if */
+ break;
+
+ case 's': /* set point size */
+ fscanf(fp, "%d", &n);
+ setsize(t_size(n));
+ break;
+
+ case 'f': /* use this font */
+ fscanf(fp, "%s", str);
+ setfont(t_font(str));
+ break;
+
+ case 'b':
+ fscanf(fp, "%d", &n);
+ oput(n);
+ break;
+
+ case 'W':
+ fscanf(fp, "%d", &n);
+ putint(n);
+ break;
+
+
+ case '#': /* comment */
+ while ( (c = getc(fp)) != '\n' && c != EOF ) ;
+ break;
+
+ } /* End switch */
+
+ } /* End while */
+
+} /* End of nconv */
+
+
+/*****************************************************************************/
+
+
diff --git a/troff/troff.d/devaps/daps.c b/troff/troff.d/devaps/daps.c
new file mode 100644
index 000000000000..4968562e4b7b
--- /dev/null
+++ b/troff/troff.d/devaps/daps.c
@@ -0,0 +1,2995 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "daps.c 1.6 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)daps.c 1.8 (gritter) 7/9/06
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+char *xxxvers = "troff.d/devaps/daps.c 1.2";
+
+
+
+/****************************************************************************
+ * *
+ * This is the post-processor for the APS-5 phototypesetter. The *
+ * language that is accepted by this program is produced by the new device *
+ * independent troff, and consists of the following statements, *
+ * *
+ * *
+ * sn set the point size to n *
+ * fn set the typesetter font to the one in position n *
+ * cx output the ASCII character x *
+ * Cxyz output the code for the special character xyz. This *
+ * command is terminated by white space. *
+ * Hn go to absolute horizontal position n *
+ * Vn go to absolute vertical position n ( down is positive ) *
+ * hn go n units horizontally from current position *
+ * vn go n units vertically from current position *
+ * nnc move right nn units, then print the character c. This *
+ * command expects exactly two digits followed by the *
+ * character c. *
+ * w paddable word space - no action needed *
+ * nb a end of line ( information only - no action needed ) *
+ * pn begin page n *
+ * Dt ...\n draw operation 't': *
+ * *
+ * Dl x y line from here to x,y *
+ * Dc d circle of diameter d, left side here *
+ * De x y ellipse of axes x,y, left side here *
+ * Da u v x y arc *
+ * D~ x y x y wiggly line by x,y then x,y *
+ * *
+ * x ... \n device control functions: *
+ * *
+ * x i initialize the typesetter *
+ * x T s name of device is s *
+ * x r n h v resolution is n units per inch. h is *
+ * min horizontal motion, v is min vert. *
+ * motion in machine units. *
+ * x p pause - can restart the typesetter *
+ * x s stop - done forever *
+ * x t generate trailer - no-op for the APS *
+ * x f n s load font position n with tables for *
+ * font s. Referring to font n now means *
+ * font s. *
+ * x H n set character height to n *
+ * x S n set character slant to n *
+ * *
+ * Subcommands like i are often spelled out as "init" *
+ * *
+ * To get the post-processor running properly on your system, you may *
+ * have to make one or more of changes: *
+ * *
+ * Choose the appropriate description of your typesetter. These *
+ * values include the type of lens and the maximum master range *
+ * for your fonts. The values that you will need to adjust are *
+ * macros and defined constants located at the start of the *
+ * daps.h file. *
+ * *
+ * Make sure the variable 'typesetter' is properly initialized *
+ * to the APS-5 typesetter file on your system. If you are not *
+ * going to have daps directly drive the typesetter, you may *
+ * want to set it to the null file, and/or initialize 'tf' to *
+ * be stdout. (file daps.g) *
+ * *
+ * Make sure that the accounting file pathname 'tracct' is the *
+ * the accounting file that you want. If no accounting is to be *
+ * done then initialize it to the null string. (file daps.g) *
+ * *
+ * Check to make sure that 'fontdir' is the directory that *
+ * contains the devaps directory where your font tables are *
+ * located. (file daps.g) *
+ * *
+ * If there are no characters on your font disk that need any *
+ * adjustment in their vertical placement, then make sure that *
+ * the conditional compilation flag ADJUST is undefined. I would *
+ * recommend that you start this way to see what your font disk *
+ * really looks like. (file daps.h) *
+ * *
+ * *
+ ****************************************************************************/
+
+
+
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pwd.h>
+
+#include "aps.h" /* APS-5 opcode definitions */
+#include "dev.h" /* font and dev structure declarations */
+
+#include "daps.h" /* constant and macro definitions */
+#include "daps.g" /* global variable definitions */
+
+
+
+
+
+/*****************************************************************************/
+
+
+int
+main (int argc, char *argv[])
+
+
+{
+
+
+ /********************************************************************
+ * *
+ * This is the main program for the APS-5 post-processor. It *
+ * is responsible for calling the sequence of routines that are *
+ * needed to translate troff's new typesetter independent output *
+ * language into a form that will be understood by the APS-5 *
+ * phototypesetter. *
+ * *
+ ********************************************************************/
+
+
+ fp_debug = stderr;
+ fp_error = stderr;
+ fp_acct = stderr;
+ tf = stdout;
+
+ get_options(argc, argv); /* process the option list */
+ if ( tf != stdout ) /* need to open the file */
+ out_file();
+ init_signals(); /* set up signal handling */
+ acct_file(); /* open the accounting file */
+ process_input(argc, argv); /* translate the input files */
+ account(); /* make sure we charge this guy */
+ done(); /* finish up this job and reset the APS */
+ /*NOTREACHED*/
+ return 0;
+
+} /* End of main */
+
+
+/****************************************************************************/
+
+
+void
+get_options (int argc, char *argv[])
+
+
+{
+
+
+ int save; /* used to adjust arg_index */
+ int v_step = 0; /* vertical step in -V option */
+
+
+ int ch;
+ int i, sharpsign = 0;
+ extern char *optarg;
+ extern int optind;
+
+
+ /********************************************************************
+ * *
+ * This is the routine that processes the command line option *
+ * list. The macro SET_ARGS uses the global variable arg_index to *
+ * properly initialize the local argc and argv values, while the *
+ * macro COUNT_ARGS adjusts the value of arg_index to account for *
+ * the number of arguments that were just processed. *
+ * *
+ * The options that are currently available in this driver *
+ * are, *
+ * *
+ * -f dir - use dir as the font directory *
+ * -F dir - same *
+ * *
+ * -t - use standard output *
+ * *
+ * -r - report the number of pages *
+ * *
+ * -A - do accounting even if there is no real *
+ * accounting file. If tracct is NULL then *
+ * the accounting information is written *
+ * to stderr. This is the way things are *
+ * done on our APS. *
+ * *
+ * -b - report whether typesetter is busy or *
+ * not. Nothing is printed. *
+ * *
+ * -w - wait until typesetter is available, *
+ * then procees the job. *
+ * *
+ * -o[str] - process only this list of pages. The *
+ * list may contain single pages or page *
+ * ranges, where the latter consists of *
+ * a pair of pages separated by -. *
+ * *
+ * -s[num] - stop processing every num pages, and *
+ * HALT the typesetter. *
+ * *
+ * -v[num] - use num as the maximum vertical step *
+ * size up or down the page. The argument *
+ * num is interpreted as 10ths of a point. *
+ * *
+ * -h[str] - use str as the string to be printed *
+ * in the header. *
+ * *
+ * -H[str] - use str as the pathname of the file *
+ * whose first line contains the string *
+ * to be printed in the header. *
+ * *
+ * -d[str] - toggle the debug flags for each number *
+ * contained in the string str. If str *
+ * contains the character '*' then all of *
+ * the debug flags will be toggled. *
+ * *
+ * -D[str] - dump all of the debug information into *
+ * file str. If this option is not used *
+ * then the debugging stuff is written to *
+ * stderr. *
+ * *
+ * -L[str] - use the file str as the log file for *
+ * all error messages. If this option is *
+ * not used then all error messages will *
+ * be written to stderr. *
+ * *
+ * -I - ignore all FATAL errors. This option is *
+ * only to be used for debugging - it may *
+ * cause a core file to be written. *
+ * *
+ ********************************************************************/
+
+
+
+ SET_ARGS(save); /* MACRO - adjust internal argc and argv */
+
+ while ((ch = getopt(argc, argv, "f:F:trAbwo:s:h:H:d:D:L:Iv:c:#"))
+ != EOF) { /*read options list*/
+
+ switch ( ch ) { /* check option */
+
+ case 'f': /* font directory */
+ case 'F':
+ fontdir = optarg;
+ break;
+
+ case 't': /* use standard output */
+ tf = stdout;
+ break;
+
+ case 'r': /* print page report */
+ report = YES;
+ break;
+
+ case 'A': /* do accounting! */
+ if ( privelege == ON )
+ x_stat |= DO_ACCT;
+ break;
+
+ case 'b': /* check if busy or not */
+ busyflag = ON;
+ break;
+
+ case 'w': /* wait til APS is free */
+ waitflag = ON;
+ break;
+
+ case 'o': /* process page list */
+ outlist(optarg);
+ break;
+
+ case 's': /* stop every spage(s) */
+ spage = atoi(optarg);
+ if ( spage <= 0 ) /* illegal page number */
+ spage = 9999;
+ break;
+
+ case 'h': /* banner is in argument */
+ banner = optarg;
+ print_banner = YES;
+ break;
+
+ case 'H': /* banner is in file */
+ ban_file(optarg);
+ print_banner = YES;
+ break;
+
+ case 'd': /* selective debug */
+ debug_select(optarg);
+ break;
+
+ case 'D': /* set up debug file */
+ debug_file(optarg);
+ break;
+
+ case 'L': /* set up log file */
+ log_file(optarg);
+ break;
+
+ case 'I': /* ignore fatal errors */
+ if ( privelege == ON )
+ ignore = YES;
+ break;
+
+ case 'v': /* set max vertical step */
+ v_step = atoi(optarg);
+ if ( v_step != 0 )
+ vert_step = ( v_step > 0 ) ? v_step
+ : -v_step;
+ if ( vert_step > MAX_INT ) /* its too big */
+ vert_step = MAX_INT;
+ break;
+
+ case 'c': /* set beam cutoff */
+ if ( (cutoff = atof(optarg)) <= 0 )
+ cutoff = CUTOFF;
+ break;
+
+ case '#':
+ sharpsign = 1;
+ break;
+ default: /* didn't find it */
+ error(NON_FATAL, "illegal option %c", argv[1][1]);
+ break;
+
+ } /* End of switch */
+
+ } /* End while */
+
+ argc -= optind - 1;
+ COUNT_ARGS(save); /* MACRO - adjust arg_index */
+ if (sharpsign == 1) {
+ fprintf(stderr, "report = %d, x_stat = %o\n",
+ report, x_stat);
+ fprintf(stderr, "busyflag = %d, waitflag = %d, ignore = %d\n",
+ busyflag, waitflag, ignore);
+ fprintf(stderr, "fontdir = %s, spage = %d, banner = %s\n",
+ fontdir, spage, banner);
+ fprintf(stderr, "v_step = %d, cutoff = %g\n",
+ v_step, cutoff);
+ for (i=0; i<nolist; i+=2)
+ fprintf (stderr, "olist[%d] is %d; olist[%d] is %d.\n",
+ i, olist[i], i+1, olist[i+1]);
+ for (i=0; i<MAX_DEBUG; i+=4)
+ fprintf(stderr, "debug[%d] = %d, %d, %d, %d\n",
+ i,debug[i],debug[i+1],debug[i+2],debug[i+3]);
+ if (fp_debug != stderr)
+ fprintf(stderr, "fp_debug is %p\n", fp_debug);
+ if (fp_error != stderr)
+ fprintf(stderr, "fp_error is %p\n", fp_error);
+ if (tf != stdout)
+ fprintf(stderr, "tf is %p\n", tf);
+ }
+
+} /* End of get_options */
+
+
+/*****************************************************************************/
+
+
+void
+process_input (int argc, char *argv[])
+
+
+{
+
+
+ FILE *fp_in; /* input file descriptor */
+ int save; /* used to adjust arg_index before exit */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by main to handle the processing *
+ * of the input files from the command line. If there were no *
+ * files specified in the call then the post-processor will read *
+ * from the standard input. Otherwise it will process all of the *
+ * input files in the list, concatenating the output from each *
+ * one onto the output file. The only convention that is used for *
+ * input file names is that the character '-' as a file name will *
+ * cause the driver to read from the standard input, provided it *
+ * isn't the first 'file' in the list of input files. It would *
+ * probably be better if we chose some other character or sequence *
+ * of characters for this purpose. *
+ * *
+ ********************************************************************/
+
+
+
+ SET_ARGS(save); /* MACRO - adjust argc and argv */
+
+ if ( argc <= 1 ) conv(stdin); /* no more args - use stdin */
+ else { /* read input file list */
+ while ( --argc > 0 ) { /* rest of the args are input files */
+
+ if ( strcmp(*++argv, "-") == 0 ) /* use standard input */
+ fp_in = stdin;
+ else if ( (fp_in = fopen(*argv, "r")) == NULL ) {
+ error(FATAL, "can't open input file %s", *argv);
+ continue; /* in case we ignore this error */
+ } /* End else */
+
+ conv(fp_in); /* translate the file */
+ if ( fp_in != stdin ) /* probably don't need it anymore */
+ fclose(fp_in);
+
+ } /* End of while */
+ } /* End else */
+
+ COUNT_ARGS(save); /* MACRO - adjust arg_index */
+
+} /* End of process_input */
+
+
+/****************************************************************************/
+
+
+void
+init_signals (void)
+
+
+{
+
+
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by main to set up the appropriate *
+ * handling of external signals for the post-processor. As *
+ * currently written interrupts, quits and hangups are all either *
+ * ignored or processed by the routine wrap_up(). *
+ * *
+ ********************************************************************/
+
+
+
+ signal(SIGFPE, float_err); /* catch floating point errors */
+
+ if ( signal(SIGINT, wrap_up) == SIG_IGN ) { /* ignoring interrupts */
+ signal(SIGINT, SIG_IGN); /* so reset SIGINT */
+ signal(SIGQUIT, SIG_IGN); /* and ignore the rest */
+ signal(SIGHUP, SIG_IGN);
+ } else { /* wrap_up() handles them */
+ signal(SIGQUIT, wrap_up);
+ signal(SIGHUP, wrap_up);
+ } /* End if */
+
+} /* End of init_signals */
+
+
+/*****************************************************************************/
+
+
+void
+debug_select (
+ char *str /* string of debug flags */
+)
+
+
+{
+
+
+ int index; /* single debug flag to toggle */
+ int i; /* for loop index */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by main() when it finds the -d *
+ * option. The parameter str is a pointer to a string of comma *
+ * separated tokens from the command line that specify which of *
+ * the debug flags is to be toggled. As currently implemented the *
+ * tokens in str may consist of numbers, which specify the actual *
+ * flag to be toggled, or the character '*', which stands for all *
+ * of the available debug flags. *
+ * *
+ ********************************************************************/
+
+
+
+ while ( *str ) {
+
+ if ( isdigit(*str) ) { /* have a single debug flag */
+ STR_CONVERT(str, index); /* MACRO - get the debug flag */
+ if ( index >= 0 && index < MAX_DEBUG )
+ TOGGLE(debug[index]); /* MACRO - toggle it */
+ } else if ( *str == '*' ) /* toggle all the debug flags */
+ for ( i = 0; i < MAX_DEBUG; i++ )
+ TOGGLE(debug[i]); /* MACRO */
+
+ if ( *str != '\0' ) str++; /* skip the comma */
+
+ } /* End while */
+
+} /* End of debug_select */
+
+
+/*****************************************************************************/
+
+
+void
+debug_file (
+ char *str /* debug file pathname */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by get_options() when it finds the *
+ * -D option in the command line. The parameter str is a pointer *
+ * to the pathname of the file to be used for all of the debugging *
+ * output. If the -D option is not specified then by default all *
+ * the debug output is written to stderr. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( (fp_debug = fopen(str, "w")) == NULL ) {
+ fp_debug = stderr;
+ error(NON_FATAL, "can't open debug file %s", str);
+ } /* End if */
+
+} /* End of debug_file */
+
+
+/*****************************************************************************/
+
+
+void
+log_file (
+ char *str /* log file pathname */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to open the log file for the APS-5 *
+ * post-processor. The pathname of the file is passed in the *
+ * parameter str when this routine is called from get_options(). *
+ * If the log file isn't specified then the post-processor will *
+ * write all of it's error messages to stderr. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( (fp_error = fopen(str, "a")) == NULL ) {
+ fp_error = stderr;
+ error(FATAL, "can't open log file %s", str);
+ } /* End if */
+
+} /* End of log_file */
+
+
+/*****************************************************************************/
+
+
+void
+acct_file (void)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to open the accounting file whose *
+ * pathname is pointed to by the variable tracct. If there is no *
+ * pathname in tracct then nothing is done in this routine, while *
+ * if we are unable to open the accounting file then an error *
+ * message is printed out and we quit. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( *tracct ) { /* we have an accnt file pathname */
+
+ if ( (fp_acct = fopen(tracct, "a")) == NULL ) { /* so open it */
+ fp_acct = stderr; /* couldn't open accounting file */
+ x_stat |= NO_ACCTFILE; /* indicate this in the exit status */
+ error(FATAL, "unable to open accounting file");
+ exit(x_stat); /* in case we ignore this error */
+ } /* End if */
+ x_stat |= DO_ACCT; /* accounting needs to be done */
+
+ } /* End if */
+
+} /* End of acct_file */
+
+
+/*****************************************************************************/
+
+
+void
+ban_file (
+ char *str /* banner file pathname */
+)
+
+
+{
+
+
+ FILE *fp_ban; /* banner file descriptor */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from get_options() to read the *
+ * banner string from the first line of the file whose pathname is *
+ * contained in the string str. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( (fp_ban = fopen(str, "r")) == NULL ) {
+ error(NON_FATAL, "can't open the banner file %s", str);
+ return;
+ } /* End if */
+
+ GET_LINE(fp_ban, ban_buf); /* MACRO - banner is first line only */
+ banner = ban_buf; /* t_banner() prints string *banner */
+
+ fclose(fp_ban); /* shouldn't need this file again */
+
+} /* End of ban_file */
+
+
+/*****************************************************************************/
+
+
+void
+out_file (void)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from the main program to open the *
+ * file pointed to by typesetter. *
+ * *
+ ********************************************************************/
+
+
+
+ do {
+ tf = fopen(typesetter, "w"); /* typesetter output file */
+ if ( busyflag == ON ) { /* report status and then exit */
+ printf(tf == NULL ? "Busy.\n" : "Available.\n");
+ exit(0);
+ } /* End if */
+
+ if ( tf == NULL ) { /* didn't open on last try */
+ if ( waitflag == OFF ) { /* he doesn't want to wait */
+ error(NON_FATAL, "can't open typesetter");
+ exit(NO_OUTFILE);
+ } /* End if */
+ else sleep(60); /* try again later */
+ } /* End if */
+ } while ( tf == NULL );
+
+} /* End of out_file */
+
+
+/*****************************************************************************/
+
+
+void
+outlist (
+ char *str /* string of pages to process */
+)
+
+
+{
+
+
+ int start, stop; /* page range end points */
+ int i; /* loop index - debug only */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called when the -o option is read in *
+ * the command line. The parameter str points to a list of page *
+ * numbers to be processed. This list consists single pages or *
+ * page ranges, separated by commas. A page range is specified by *
+ * separating two page numbers by the character '-'. In this case *
+ * all pages in this closed interval will be processed by daps. *
+ * *
+ ********************************************************************/
+
+
+
+ while ( *str && nolist < MAX_OUTLIST - 2 ) {
+
+ start = 0;
+
+ if ( isdigit(*str) ) /* page number should begin here */
+ STR_CONVERT(str,start); /* MACRO - get left end point */
+ else start = -9999; /* use lowest possible page */
+
+ stop = start; /* in case it is a single page */
+
+ if ( *str == '-' ) { /* have a page range */
+ str++; /* so skip the minus sign */
+ if ( isdigit(*str) ) /* page number begins here */
+ STR_CONVERT(str,stop); /* MACRO - get right end point */
+ else stop = 9999; /* use largest possible page */
+ } /* End if */
+
+ if ( start > stop )
+ error(FATAL,"illegal range %d-%d",start,stop);
+
+ olist[nolist++] = start; /* save the page range */
+ olist[nolist++] = stop;
+
+ if ( *str != '\0' ) str++; /* skip the comma */
+
+ } /* End while */
+
+ olist[nolist] = 0; /* terminate the page list */
+
+ if ( *str ) /* too many pages for olist array */
+ error(NON_FATAL, "skipped pages %s", str);
+
+ if ( debug[1] ) /* dump the olist[] array */
+ for ( i = 0; i < nolist; i += 2 )
+ fprintf(fp_debug,"%3d %3d\n", olist[i], olist[i+1]);
+
+} /* End of outlist */
+
+
+/*****************************************************************************/
+
+
+void
+error (
+ int kind, /* kind of error ie. FATAL or NON_FATAL */
+ char *str, /* pointer to message to be printed */
+ ...
+)
+
+
+{
+
+
+ /********************************************************************
+ * *
+ * This routine is called when the post-processor has found *
+ * an internal error. The parameter kind has the value FATAL or *
+ * NON_FATAL, and accordingly determines whether processing will *
+ * continue or not. The parameter str is a pointer to the error *
+ * message that is to be printed. All the remaining parameters *
+ * are the arguments that may be referenced in the control string *
+ * str. *
+ * *
+ * The global variable ignore is initialized to NO in the *
+ * file daps.globals, and can be set to YES by using the -I option *
+ * in the command line. This will allow the post-processor to *
+ * continue after a normally FATAL error has been encountered. *
+ * This is only a debugging feature and should not generally be *
+ * used. *
+ * *
+ ********************************************************************/
+
+
+ va_list ap;
+
+ fprintf(fp_error, "daps: ");
+ if ( (kind == NON_FATAL) && (line_number > 0) )
+ fprintf(fp_error, "warning - ");
+ va_start(ap, str);
+ vfprintf(fp_error, str, ap);
+ va_end(ap);
+
+ if ( line_number > 0 )
+ fprintf(fp_error, " ( line = %ld )", line_number);
+ fprintf(fp_error, "\n");
+
+ if ( ignore == YES && privelege == ON )
+ return;
+
+ if ( kind == FATAL ) /* can't ignore this error */
+ wrap_up(0); /* so quit */
+
+} /* End of error */
+
+
+/*****************************************************************************/
+
+
+int
+done (void)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to do the final processing for the *
+ * current job. If there is to be any accounting for this job we *
+ * need to be sure that the account function is called first *
+ * because there is nothing more we can do when we get here. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( tf == NULL ) /* Nowhere to write */
+ exit(x_stat | NO_OUTFILE); /* so set the bit in x_stat and quit */
+
+ t_reset('s'); /* get APS ready for the next job */
+ exit(x_stat); /* quit with status x_stat */
+
+} /* End of done */
+
+
+/*****************************************************************************/
+
+
+void
+float_err (
+ int sig /* signal number - not used */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * Called when a floating point error has been detected. *
+ * Needed because we want to make sure we exit gracefully if a *
+ * users job would normally dump a core file. *
+ * *
+ ********************************************************************/
+
+
+
+ error(FATAL, "floating point exception");
+
+} /* End of float_err */
+
+
+/*****************************************************************************/
+
+
+void
+wrap_up (
+ int sig /* signal number - not used */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to make sure that all the necessary *
+ * stuff is done when the driver finishes its job because of some *
+ * external signal or because it encountered a FATAL syntax error. *
+ * *
+ ********************************************************************/
+
+
+
+ account(); /* keep some kind of record for this job */
+ done(); /* get the APS ready for next job */
+
+} /* End of wrap_up */
+
+
+/*****************************************************************************/
+
+
+void
+conv(
+
+
+ register FILE *fp /* input file descriptor */
+)
+
+
+{
+
+
+ register int ch; /* first character of the command */
+ int c; /* used only as a character */
+ int n; /* general purpose integer variable */
+ char str[100], buf[300]; /* buffers for fscanf and fgets */
+
+
+
+ /********************************************************************
+ * *
+ * This is the main interpreter for the post-processor. It is *
+ * called from routine process_input with the single parameter *
+ * fp, which is the file descriptor for the current input file. *
+ * *
+ * The global variable line_number is used to keep track of *
+ * the current line in the input file fp. Its value is adjusted *
+ * in both conv() and devcntrl() and it is used in the routine *
+ * error() when error messages are written to the file fp_error. *
+ * *
+ * The bits in the global variable x_stat are used to keep *
+ * track of the progress of the post-processor, and when the *
+ * program exits it will return x_stat as its termination status. *
+ * *
+ * *
+ * NOTE - In order to improve the speed of this routine we may *
+ * want to declare more register variables. When we do this we *
+ * need to be sure that the macros that are being used will accept *
+ * register variables as arguments. For example if a macro takes *
+ * the address of one of its arguments, then we can't assign this *
+ * variable to a register. *
+ * *
+ ********************************************************************/
+
+
+
+ x_stat |= FILE_STARTED; /* indicate this in x_stat */
+ line_number = 1; /* line in current input file */
+
+ while ( (ch = getc(fp) ) != EOF ) {
+
+ switch ( ch ) { /* ch determines the command */
+
+ case 'w': /* don't do anything for these */
+ case ' ':
+ case 0:
+ break;
+
+ case '\n': /* just increment line_number */
+ line_number++;
+ break;
+
+ case '0': /* two motion digits and a char */
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ GET_DIG(fp, c); /* MACRO - get the second digit */
+ hmot((ch - '0') * 10 + c - '0');
+
+ /* Be careful - we need to fall through here */
+
+ case 'c': /* single ASCII character */
+ GET_CHAR(fp, c); /* MACRO - read the character */
+ put1(c); /* output c's APS-5 code */
+ break;
+
+ case 'h': /* relative horizontal motion */
+ case 'H': /* absolute horizontal motion */
+ case 'v': /* relative vertical motion */
+ case 'V': /* absolute vertical motion */
+ case 's': /* set point size */
+ case 'p': /* start a new page */
+ GET_INT(fp, n); /* MACRO - first get an integer */
+ switch( ch ) { /* and then process the command */
+
+ case 'h': hmot(n);
+ break;
+
+ case 'H': hgoto(n);
+ break;
+
+ case 'v': vmot(n);
+ break;
+
+ case 'V': vgoto(n);
+ break;
+
+ case 's': setsize(t_size(n));
+ break;
+
+ case 'p': t_page(n);
+ break;
+
+ } /* End switch */
+ break;
+
+ case 'C': /* process special char string */
+ case 'f': /* set font */
+ GET_STR(fp, str); /* MACRO - first get a string */
+ if ( ch == 'C' )
+ put1s(str);
+ else setfont(t_font(str));
+ break;
+
+ case 'x': /* device control function */
+ devcntrl(fp);
+ break;
+
+ case 'D': /* drawing operation */
+ case 't': /* text string upto newline */
+ GET_LINE(fp, buf); /* MACRO - get rest of the line */
+ if ( ch == 'D' )
+ drawfunct(buf, fp);
+ else t_text(buf);
+ line_number++; /* finished with this line */
+ break;
+
+ case 'n': /* end of line */
+ case '#': /* comment */
+ SKIP_LINE(fp,c); /* MACRO - skip rest of this line */
+ if ( ch == 'n' )
+ t_newline();
+ line_number++;
+ break;
+
+ default: /* illegal command - quit */
+ error(FATAL,"unknown input character 0%o %c", ch, ch);
+ break; /* in case we ignore this error */
+
+ } /* End switch */
+
+ } /* End while */
+
+ x_stat &= ~FILE_STARTED; /* turn off FILE_STARTED bit in x_stat */
+
+} /* End of conv */
+
+
+/*****************************************************************************/
+
+
+void
+drawfunct(
+
+
+ char buf[], /* drawing command */
+ FILE *fp
+)
+
+
+{
+
+
+ int n1, n2, n3, n4; /* values are set in the MACROS */
+
+
+
+ /********************************************************************
+ * *
+ * This routine interprets the drawing functions that are *
+ * provided by troff. The array buf[] has been filled in by the *
+ * function conv(), and it contains the drawing command line from *
+ * the input file. *
+ * *
+ ********************************************************************/
+
+
+
+ switch ( buf[0] ) { /* process the command */
+
+ case 'l': /* draw a line */
+ SCAN2(buf+1, n1, n2); /* MACRO - get two integers */
+ drawline(n1, n2, ".");
+ break;
+
+ case 'c': /* draw a circle */
+ SCAN1(buf+1, n1); /* MACRO - get one integer */
+ drawcirc(n1);
+ break;
+
+ case 'e': /* draw an ellipse */
+ SCAN2(buf+1, n1, n2); /* MACRO - get two integers */
+ drawellip(n1, n2);
+ break;
+
+ case 'a': /* draw an arc */
+ SCAN4(buf+1,n1,n2,n3,n4); /* MACRO - get four integers */
+ drawarc(n1, n2, n3, n4);
+ break;
+
+ case '~': /* draw spline curve */
+ drawwig(buf+1);
+ break;
+
+#ifdef PLOT
+ case 'p': /* plot these points */
+ plot_points(buf+1, fp);
+ break;
+#endif
+ default: /* don't understand the command */
+ error(FATAL, "unknown drawing function %s", buf);
+ break; /* in case we ignore this error */
+
+ } /* End switch */
+
+} /* End of drawfunct */
+
+
+/*****************************************************************************/
+
+
+void
+devcntrl(
+
+
+ FILE *fp /* input file descriptor */
+)
+
+
+{
+
+
+ int c; /* character used in SKIP_LINE */
+ int n; /* integer used in GET_INT */
+ char str[20]; /* used to hold different strings */
+ char file[50]; /* load from this font file - maybe */
+ char buf[4096]; /* buffer used in GET_LINE etc. */
+
+
+
+ /********************************************************************
+ * *
+ * This is the interpreter for the device control language *
+ * that is produced by the new troff. The parameter fp is the file *
+ * descriptor for the current input file. *
+ * *
+ ********************************************************************/
+
+
+
+ GET_STR(fp, str); /* read command from input file */
+
+ switch ( str[0] ) { /* str[0] determines the command */
+
+ case 'i': /* initialize the device */
+ fileinit(); /* read data from DESC.out */
+ t_init(); /* initialize the typesetter */
+ if ( print_banner == YES ) /* print the job's banner */
+ t_banner();
+ break;
+
+ case 'T': /* set device name */
+ GET_STR(fp, devname); /* MACRO - get device string */
+ if ( strcmp(devname, "aps") != SAME_STR )
+ error(FATAL, "illegal typesetter %s", devname);
+ break;
+
+ case 't': /* trailer - do nothing on APS-5 */
+ break;
+
+ case 'p': /* pause - we can restart */
+ case 's': /* stop - done with this job */
+ t_reset(str[0]); /* reset the typesetter */
+ break;
+
+ case 'r': /* set resolution */
+ GET_INT(fp, res); /* MACRO - get one integer */
+ hcutoff = cutoff * res; /* beam cutoff in device units */
+ break;
+
+ case 'f': /* load a font */
+ GET_INT(fp, n); /* MACRO - put font number in n */
+ GET_STR(fp, str); /* MACRO - put font name in str */
+ GET_LINE(fp, buf); /* MACRO - use this filename */
+ ungetc('\n', fp); /* put '\n' back for SKIP_LINE */
+ file[0] = 0; /* in case there is no file name */
+ SCAN_STR(buf, file); /* MACRO - may have a file name */
+ loadfont(n, str, file);
+ break;
+
+ case 'H': /* set character height */
+ GET_INT(fp, n); /* MACRO - read vertical point size */
+ t_charht(t_size(n));
+ break;
+
+ case 'S': /* set character slant */
+ GET_INT(fp, n); /* MACRO - read APS slant angle */
+ t_slant(n); /* set the APS slant to n */
+ last_req_slant = n; /* and remember this angle */
+ break;
+
+ case 'X':
+ GET_STR(fp, buf);
+ if (strcmp(buf, "LC_CTYPE") == 0)
+ break;
+ /*FALLTHRU*/
+
+ default: /* don't understand the command */
+ error(FATAL, "unknown device command %c", str[0]);
+ break; /* in case we ignore this error */
+
+ } /* End switch */
+
+ SKIP_LINE(fp, c); /* finished with this line */
+ line_number++;
+
+} /* End of devcntrl */
+
+
+/*****************************************************************************/
+
+
+void
+t_init (void)
+
+
+{
+
+
+ int i; /* for loop variable */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from devcntrl() when the command *
+ * x init is read. It produces the instructions that initialize *
+ * the APS, and then it sets up the picture drawing variables *
+ * drawdot and drawsize. *
+ * *
+ * *
+ * NOTE - the opcode STRTJOB is defined to be octal 272 in the *
+ * file aps.h, although on our APS-5 typesetter it is one of the *
+ * reserved but not implemented opcodes. *
+ * *
+ ********************************************************************/
+
+
+
+ PUTC(STRTJOB, tf); /* MACRO - output STRTJOB opcode */
+ putint(1); /* dummy argument for STRTJOB? */
+ PUTC(STRTPG, tf); /* MACRO - start page 0 */
+ putint(0);
+
+ hpos = vpos = 0; /* initialize page coordinates */
+
+ for ( i = 0; i < nchtab; i++ ) /* find drawing character index */
+ if ( strcmp(&chname[chtab[i]], "l.") == SAME_STR )
+ break;
+
+ if ( i < nchtab ) { /* found it in the table */
+ drawdot = i + 128; /* so use these values for drawing */
+ drawsize = 1;
+ } else { /* didn't find it - use default */
+ drawdot = '.';
+ drawsize = 3;
+ } /* End if */
+
+} /* End of t_init */
+
+
+/*****************************************************************************/
+
+
+void
+t_banner (void)
+
+
+{
+
+
+ int i; /* while loop counter */
+ char *bp; /* temp pointer to banner string */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from devcntrl() when the device *
+ * initialization command is read. It is responsible for printing *
+ * the job's header. This includes checking and then writing out *
+ * the string pointed to by banner. The user may set this string *
+ * by using either the -h or the -H options on the command line. *
+ * *
+ ********************************************************************/
+
+
+
+ output = ON; /* ON for routine put1() etc. */
+ bp = banner; /* point to start of banner string */
+ i = 0; /* characters looked at so far */
+
+ while ( *bp ) /* check at most BAN_LENGTH chars */
+ if ( *bp++ < ' ' || ++i > BAN_LENGTH ) /* unprintable or too long */
+ *(--bp) = '\0'; /* so last char is as far as we go */
+
+ setsize(t_size(BAN_SIZE)); /* use font 1 and point size BAN_SIZE */
+
+ vmot(VSPACE0); /* space down for banner cut marks */
+ t_text(cut_marks); /* print first set of cut marks */
+ hmot(HSPACE0); /* space right for more cut marks */
+ t_text(cut_marks); /* print second set of cut marks */
+
+ vmot(VSPACE1); /* skip this far before banner */
+ hgoto(HSPACE1); /* indent */
+ t_text(ban_sep); /* start of banner */
+
+ vmot(VSPACE2); /* space down for banner string */
+ hgoto(HSPACE2); /* indent */
+ t_text(banner); /* print the user's banner */
+
+ vmot(VSPACE3); /* skip down for next separator */
+ hgoto(HSPACE3); /* indent */
+ t_text(ban_sep); /* print the second separator */
+
+ vmot(VSPACE4); /* skip down for banner cut marks */
+ hgoto(HSPACE4); /* position for first cut marks */
+ t_text(cut_marks); /* print first set of cut marks */
+ hmot(HSPACE0); /* skip right for second cut marks */
+ t_text(cut_marks); /* print second set */
+
+ hpos = vpos = 0; /* reset these guys again */
+ cur_vpos = max_vpos = 0; /* user doesn't own the banner */
+ print_banner = NO; /* don't print it again */
+ output = OFF; /* output is controlled in t_page() */
+
+} /* End of t_banner */
+
+
+/*****************************************************************************/
+
+
+void
+t_page (int n)
+
+
+{
+
+
+ int i; /* for loop index */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from conv() to do the work that is *
+ * necessary when we begin a new page. The STRTPG command to the *
+ * APS-5 invokes the RESET command which sets the font to 0000, *
+ * the master range to 1, and sets the oblique mode to normal and *
+ * the oblique angle to 14 degrees. To reset the font and range *
+ * properly we call setsize(), while if we were in oblique mode *
+ * the variable aps_slant will be non-zero and so in this case *
+ * we call routine t_slant() with aps_slant as the parameter. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == ON && ++scount >= spage ) { /* reached stop page */
+ t_reset('p'); /* so reset the APS and then HALT */
+ scount = 0; /* and start counting over again */
+ } /* End if */
+
+ vpos = 0; /* we are at the top of new page */
+ output = ON; /* enable output in put1() etc. */
+ last_slant = POS_SLANT; /* this will be the stored angle */
+
+ PUTC(STRTPG, tf); /* MACRO - start page n */
+ putint(n);
+ ++pageno; /* update user's page number */
+
+ setsize(size); /* reset both the font and size */
+ if ( aps_slant ) /* then the APS was in oblique mode */
+ t_slant(aps_slant); /* so go back to previous slant */
+
+ if ( nolist == 0 ) return; /* no -o option, so print every page */
+ output = OFF; /* otherwise -o option was specified */
+ for ( i = 0; i < nolist; i += 2 ) /* so check page pairs in olist[] */
+ if ( n >= olist[i] && n <= olist[i+1] ) {
+ output = ON; /* enable output for this page */
+ break;
+ } /* End if */
+
+} /* End of t_page */
+
+
+/*****************************************************************************/
+
+
+void
+t_newline (void)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from conv() when it has read the *
+ * start new line command. This command has the form "n a b" where *
+ * a and b are integers that we can safely ignore for the APS-5. *
+ * *
+ ********************************************************************/
+
+
+
+ hpos = 0; /* return to left margin */
+
+} /* End of t_newline */
+
+
+/*****************************************************************************/
+
+
+int
+t_size (
+ int n /* convert this point size */
+)
+
+
+{
+
+ int i; /* for loop index */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to convert the point size n to an *
+ * internal size, which is defined as one plus the index of the *
+ * least upper bound for n in the array pstab[]. If n is larger *
+ * than all the entries in pstab[] then nsizes is returned. *
+ * *
+ * *
+ * NOTE - this routine expects the entries in pstab[] to be in *
+ * increasing numerical order, but it doesn't require this list to *
+ * be terminated by a 0 point size entry. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( n >= pstab[nsizes-1] ) /* greater than all entries */
+ return(nsizes); /* so use largest internal size */
+
+ for ( i = 0; n > pstab[i]; i++ ) /* otherwise find the LUB for n */
+ ;
+ return(i+1); /* internal size is i+1 */
+
+} /* End of t_size */
+
+
+/*****************************************************************************/
+
+
+void
+t_charht (
+ int n /* set height to this internal size */
+)
+
+
+{
+
+
+ int max; /* max internal size for current range */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by devcntrl() to set the height of *
+ * the characters that are being printed to the internal size *
+ * specified by the parameter n. If the requested size is too *
+ * large for the current range then an error message is written *
+ * and the requested size is set to the maximum allowed in the *
+ * current range. Since the APS-5 apparently allows us to decrease *
+ * the height as far as we want, no lower limit checks are made on *
+ * the requested size. The global variable range is set by the *
+ * routine setfont() to the current master range that is being *
+ * used. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( range < 1 || range > MAX_RANGE ) { /* something is wrong here */
+ error(FATAL, "illegal master range %d", range);
+ return; /* in case this error is ignored */
+ } /* End if */
+
+ max = upper_limit(range); /* internal upper limit for range */
+
+ if ( n > max ) { /* requested size is too big */
+ error(NON_FATAL, "size %d too large for range %d", pstab[n-1], range);
+ n = max; /* reset n to largest allowed size */
+ } /* End if */
+
+ PUTC(VSIZE, tf); /* MACRO - set character height */
+ putint(10 * pstab[n-1]); /* vertical size - in decipoints */
+
+} /* End of t_charht */
+
+
+/*****************************************************************************/
+
+
+int
+upper_limit (
+ int n /* find upper limit for this range */
+)
+
+
+{
+
+
+ int bsize; /* master range base size */
+ int max; /* maximum point size for range n */
+ int max_internal; /* maximum internal size for range n */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by t_charht() and possibly others to *
+ * find the maximum internal size that is allowed for master range *
+ * n. The value returned to the caller is the largest internal *
+ * size that is allowed in this range. *
+ * *
+ ********************************************************************/
+
+
+
+ bsize = BASE_SIZE(n); /* base size for master range n */
+ max = bsize; /* max point size if n > 3 */
+ if ( n <= 3 ) /* can scale these ranges up */
+ max = SCALE_UP(bsize); /* to this limit on our APS-5 */
+
+ max_internal = t_size(max); /* first try at max internal size */
+ if ( pstab[max_internal -1] > max ) /* take next lower internal size */
+ max_internal--;
+
+ return(max_internal);
+
+} /* End of upper_limit */
+
+
+/*****************************************************************************/
+
+
+void
+t_slant (
+ int n /* set the APS slant to this value */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * Called to set the slant angle to the value of the parameter *
+ * n. On the APS-5 we can only set positive or negative 14 degree *
+ * slants, even though in TROFF any slant angle can be requested. *
+ * The global variable last_slant is the value of the last angle *
+ * that was stored in the APS-5 using either the SETOBLIQUE or *
+ * STRTPG commands, while aps_slant is the last angle we set in *
+ * this routine. *
+ * *
+ * Originally we only set the oblique angle if last_slant *
+ * was not equal to n. This really didn't work too well, because *
+ * appaerntly the APS-5 resets the oblique angle to +14 degrees *
+ * when it returns to normal mode. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( n != 0 ) { /* need to slant type being set */
+
+ n = ( n > 0 ) ? POS_SLANT /* use +14 degree slant */
+ : NEG_SLANT; /* otherwise slant at -14 degrees */
+
+ PUTC(SETOBLIQUE, tf); /* MACRO - store new angle n */
+ putint(10 * n); /* APS expects 10 times the angle */
+ last_slant = n; /* remember this stored angle */
+
+ PUTC(XOBLIQUE, tf); /* MACRO - execute oblique mode */
+
+ } /* End if */
+ else PUTC(XNORMAL, tf); /* MACRO - otherwise use normal mode */
+
+ aps_slant = n; /* angle that type is being set at */
+
+} /* End of t_slant */
+
+
+/*****************************************************************************/
+
+
+int
+t_font (
+ char *str /* convert this string to font number */
+)
+
+
+{
+
+
+ int n; /* integer value for number in str */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from conv() to convert the ASCII *
+ * string *str to an integer that represents a legal font number. *
+ * If the resulting number is outside the allowed range for fonts *
+ * on this typesetter then an error message is printed out and *
+ * the program is aborted. *
+ * *
+ ********************************************************************/
+
+
+
+ n = atoi(str); /* font number */
+ if ( n < 0 || n > nfonts ) { /* illegal font - abort */
+ error(FATAL, "illegal font number %d", n);
+ n = font; /* in case we don't quit on an error */
+ } /* End if */
+
+ return(n); /* legal value so return it */
+
+} /* End of t_font */
+
+
+/*****************************************************************************/
+
+
+void
+t_text (
+ char *str /* typeset this string of characters */
+)
+
+
+{
+
+
+ int ch; /* internal character variable */
+ char buf[4]; /* buffer used for special chars */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by conv() to process the text string *
+ * that is in the array str. Characters are read from str and *
+ * written to the output file until the end of the string is *
+ * reached. *
+ * *
+ * After the character has been put in the output file the *
+ * current horizontal position is adjusted by a call to hmot() *
+ * using the global variable lastw as the parameter. lastw is set *
+ * in put1() and represents the width of the last character that *
+ * was printed. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( debug[2] )
+ fprintf(fp_debug,"input string = %s\n", str);
+
+ if ( output == OFF ) return; /* not doing output on this page */
+
+ while ( (ch = *str++) != '\n' && ch != '\0' ) {
+
+ if ( ch == '\\' ) { /* this is a special char sequence */
+ switch ( ch = *str++ ) { /* so check the next character */
+
+ case '(': /* special troff character sequence */
+ buf[0] = *str++;
+ buf[1] = *str++;
+ buf[2] = '\0';
+ put1s(buf);
+ break;
+
+ case '\\': /* backslash character */
+ case 'e':
+ put1('\\');
+ break;
+
+ default: /* illegal character sequence */
+ error(FATAL,"illegal character sequence \\%c", ch);
+ break;
+
+ } /* End switch */
+ } else put1(ch); /* otherwise it is a simple character */
+ hmot(lastw); /* beam has moved right lastw units */
+
+ if ( debug[3] )
+ fprintf(fp_debug,"char = %c width = %d\n", ch, lastw);
+
+ } /* End while */
+
+} /* End of t_text */
+
+
+/*****************************************************************************/
+
+
+void
+t_reset (
+ int ch /* pause or stop */
+)
+
+
+{
+
+
+ int n; /* for loop variable */
+ long dist; /* distance to end of job */
+ int opcode; /* ENDJOB or HALT */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to produce the typesetter commands *
+ * that are required at the end of a job. If the parameter ch has *
+ * the value 's' then we have reached the end of the current job *
+ * and so we output the ENDJOB opcode, otherwise ch should be *
+ * equal to 'p', and so we produce the HALT command. This enables *
+ * the operator to restart the current job by pressing the PROCEED *
+ * button on the front panel, while if he hits the INITIAL button *
+ * the current job will be terminated. *
+ * *
+ * If we have finished this job, but we are not currently at *
+ * position max_vpos, we step the job forward to this position so *
+ * that the next job begins on unexposed paper. *
+ * *
+ ********************************************************************/
+
+
+
+ output = ON; /* probably not needed here? */
+
+ if ( ((dist = max_vpos - cur_vpos) > 0) && (ch == 's') ) {
+ dist += (pstab[nsizes-1] / 2) * 10; /* try to get whole last line */
+ while ( dist > 0 ) { /* go to the end of the job */
+ vmot(dist > MAX_INT ? MAX_INT : dist);
+ dist -= (dist > MAX_INT) ? MAX_INT : dist;
+ } /* End while */
+ } /* End if */
+
+ PUTC(STRTPG, tf); /* MACRO - output STRTPG opcode */
+ putint(9000+pageno); /* can't possibly be a page number */
+
+ for ( n = 0; n < 10; n++ ) /* flush out APS internal buffer */
+ PUTC(APSNOOP, tf); /* MACRO - put out a few no-op's */
+
+ opcode = ( ch == 'p' ) ? HALT /* may want to restart this job */
+ : ENDJOB; /* done with this guy */
+
+ PUTC(opcode, tf); /* MACRO - stop */
+
+ fflush(tf); /* flush any buffered output */
+
+} /* End of t_reset */
+
+
+/*****************************************************************************/
+
+
+void
+hflush (void)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called in put1() and t_push() to make sure *
+ * that the two variables hpos and htrue aren't too different. If *
+ * they differ by more than the constant SLOP then a tab is set *
+ * and then executed to position the beam properly. *
+ * *
+ * The variable hpos is the current horizontal position as *
+ * determined by troff, while htrue is the horizontal position as *
+ * calculated by the post-processor. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == OFF ) return; /* not doing output for this page */
+
+ if ( abs(hpos - htrue) > SLOP ) { /* positions are too different */
+ PUTC(SETTAB, tf); /* MACRO - so set a tab */
+ putint(hpos); /* to the current value of hpos */
+ PUTC(XTAB, tf); /* MACRO - then execute the tab */
+ htrue = hpos; /* the positions are the same now */
+ } /* End if */
+
+} /* End of hflush */
+
+
+/*****************************************************************************/
+
+
+void
+hmot (
+ int n /* move this far from here */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from conv() to handle a relative *
+ * horizontal motion of n units. If n is positive then we move to *
+ * the right on the current line. If the final horizontal position *
+ * hpos is negative then something has gone wrong and so we print *
+ * out an error message and if we return from error() we set hpos *
+ * to 0. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( (hpos += n ) < 0 || hpos > hcutoff ) { /* bad beam position */
+ error(FATAL, "illegal horizontal position %d", hpos);
+ hpos = 0; /* in case we ignore this error */
+ } /* End if */
+
+} /* End of hmot */
+
+
+/*****************************************************************************/
+
+
+void
+hgoto (
+ int n /* move to this horizontal position */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by conv() to set the absolute *
+ * horizontal position of the beam to the position n, where n *
+ * must be a positive integer. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( (hpos = n) < 0 || hpos > hcutoff ) { /* bad beam position */
+ error(FATAL, "illegal horizontal position %d", hpos);
+ hpos = 0; /* in case we ignore this error */
+ } /* End if */
+
+} /* End of hgoto */
+
+
+/*****************************************************************************/
+
+
+void
+vgoto (
+ int n /* final absolute vert position */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called from conv() to position the beam at *
+ * the absolute vertical position n. The unit used in all of the *
+ * APS absolute spacing commands is 1/10 of a point. *
+ * *
+ * *
+ * NOTE - it is important to check that a job doesn't try to *
+ * write on a previous job by using the vertical spacing commands. *
+ * Currently this check is made in the routine vmot(). *
+ * *
+ ********************************************************************/
+
+
+
+ vmot(n - vpos); /* move n-vpos units from here */
+
+} /* End of vgoto */
+
+
+/*****************************************************************************/
+
+
+void
+vmot (
+ int n /* move n units vertically from here */
+)
+
+
+{
+
+
+ int sign; /* sign of the requested motion */
+ int dist; /* distance left to move */
+
+
+ /********************************************************************
+ * *
+ * This routine is called to move the vertical position of the *
+ * beam n units from the current position. The global variable *
+ * cur_vpos is the typesetter's current vertical position as *
+ * measured from the start of the job. If the user has requested *
+ * a relative vertical motion that would make cur_vpos negative *
+ * we print an error message and then abort. The variable max_vpos *
+ * is the maximum vertical position that this job has reached. It *
+ * is used to calculate the amount of paper that has been used. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == OFF ) return; /* not doing output on this page */
+
+ if ( cur_vpos + n < 0 ) { /* trying to write on last job! */
+ error(FATAL, "can't backup past start of job");
+ return; /* in case we ignore this error */
+ } /* End if */
+
+ sign = ( n > 0 ) ? 1 : -1; /* up or down the page */
+ dist = sign * n; /* total distance to move */
+
+ while ( dist > 0 ) { /* not done yet */
+ PUTC(VSPABS, tf); /* MACRO - absolute vert motion */
+ putint(sign * ((dist > vert_step) ? vert_step : dist));
+ dist -= ( dist > vert_step ) ? vert_step : dist ;
+ } /* End while */
+
+ vpos += n; /* record our new vertical position */
+ cur_vpos += n;
+ if ( cur_vpos > max_vpos ) /* this is the farthest we have gone */
+ max_vpos = cur_vpos;
+
+} /* End of vmot */
+
+
+/*****************************************************************************/
+
+
+void
+put1s (
+ char *s /* print this special character */
+)
+
+
+{
+
+
+ int i; /* for loop index */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to produce the typesetter output *
+ * for the special character string pointed to by s. All of the *
+ * special characters are listed in the charset portion of the *
+ * typsetter's DESC file, and the program makedev reads this part *
+ * of the DESC file and produces two tables called chtab[] and *
+ * chname[]. The character array chname[] contains the special *
+ * character strings separated by '\0', while chtab[i] gives us *
+ * the starting position in chname[] for the special character i. *
+ * *
+ * *
+ * NOTE - Since we just do a sequential search of the strings *
+ * in chname[] when looking for a special character, the speed of *
+ * the post-processor could be improved if we had the most common *
+ * special characters at the start of the list in the DESC file. *
+ * However before doing this we should find out how troff does *
+ * the lookup. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == OFF ) return; /* not doing output for this page */
+
+ for ( i = 0; i < nchtab; i++ ) /* lookup the special character */
+ if ( strcmp(&chname[chtab[i]], s) == SAME_STR )
+ break;
+
+ if ( i < nchtab ) { /* found it */
+#ifdef ADJUST
+ t_adjust(s); /* adjust vertical positions */
+#endif
+ put1(i + 128); /* special characters start at 128 */
+ } /* End if */
+ else /* didn't find it - abort */
+ if ( newfile(s, pstab[size-1]) )
+ error(FATAL, "special character %s not found", s);
+
+ if ( debug[4] ) {
+ fprintf(fp_debug,"string = %s ", s);
+ fprintf(fp_debug,"index = %d\n", i);
+ } /* End if */
+
+} /* End of put1s */
+
+
+/*****************************************************************************/
+
+
+#ifdef ADJUST
+
+
+void
+t_adjust (
+ char *s /* look for this string */
+)
+
+
+{
+
+
+ int i; /* for loop index */
+ int incr; /* incrment v_adjust by this much */
+
+
+
+ /********************************************************************
+ * *
+ * Called from put1s() to look for the string *s in adj_tbl[] *
+ * and if found it is used to set the appropriate vertical for the *
+ * character. *
+ * *
+ ********************************************************************/
+
+
+ v_adjust = 0;
+
+ for ( i = 0; adj_tbl[i] != '\0'; i++ )
+ if ( strcmp(s, adj_tbl[i]) == 0 ) {
+ incr = (vadjustment[i] < 0) ? -1 : 1;
+ v_adjust = (vadjustment[i] * pstab[size-1]) /dev.unitwidth + incr;
+ break;
+ } /* End if */
+
+} /* End of t_adjust */
+
+#endif
+
+
+/*****************************************************************************/
+
+
+void
+put1 (
+ int c /* print this character */
+)
+
+
+{
+
+
+ register int i = 0; /* c's index in font data structures */
+ register int k; /* look for c on this font */
+ int j; /* lookup failed on this many fonts */
+ int k1; /* if not found check this font next */
+ int code; /* APS-5 code for this character */
+ int old_font; /* original font number (1..nfonts) */
+ int old_range; /* original master range setting */
+ int last_range; /* last master range setting */
+ int old_slant; /* original device slant angle */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is responsible for producing the output codes *
+ * for the characters to be printed by the APS. The integer c *
+ * is the ASCII code for the character if c < 128. Otherwise it *
+ * refers to one of troff's special character sequences. Since we *
+ * are not concerned with unprintable ASCII characters we subtract *
+ * 32 from c to get the right index to use when we do the lookup *
+ * in array fitab[][]. If the character isn't found on the current *
+ * font then we search all the remaining fonts, starting with the *
+ * first special font. If we haven't found the character after we *
+ * search the last font then an error message is written out and *
+ * we quit. Since we can't be guarenteed that font position 0 has *
+ * been loaded with a valid font, we need to make sure that the *
+ * circular search skips this position. *
+ * *
+ * If we find the character c, but it has an APS code that is *
+ * larger than 128, then the makedev program has encoded some *
+ * extra information in this field. Therefore we call the routine *
+ * special_case() to decode this info, and return the correct APS *
+ * code for c. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == OFF ) return; /* not doing output on this page */
+
+ old_font = font; /* may find c on a different font */
+ old_range = last_range = range; /* and in a different master range */
+ old_slant = aps_slant; /* and may change the slant for c */
+
+ k = font; /* while loop looks for c on font k */
+ k1 = smnt - 1; /* get the next font from this guy */
+ j = 0; /* c not found on this many fonts */
+
+ c -= 32; /* tables don't include unprintable chars */
+
+ if ( c <= 0 ) { /* c is a space or unprintable */
+ if ( c < 0 ) /* can't be in any of our font tables */
+ error(FATAL, "non-printable character 0%o\n", c+32);
+
+ lastw = (widthtab[font][0] & BMASK) * pstab[size-1] / dev.unitwidth;
+ return; /* lastw = space width (see t_text()) */
+ } /* End if */
+
+
+ /* Look for character c in current font and then on the special fonts */
+
+
+ while ( (j < nfonts + 1) && ((i = fitab[k][c] & BMASK) == 0) ) {
+ k = (k1++) % nfonts + 1; /* now check all other fonts */
+ j++;
+ } /* End while */
+
+
+ /* If j > nfonts or i == 0 then char c not found. no-op if code = 0 */
+
+
+ if ( j > nfonts || i == 0 || (code = codetab[k][i] & BMASK) == 0 ) {
+ if ( i == 0 || j > nfonts )
+ if ( c+32 < 128 || newfile(&chname[chtab[c+32-128]], pstab[size-1]) )
+ error(FATAL, "character 0%o not found", c+32);
+ return;
+ } /* End if */
+
+ if ( aps_font != fontname[k].number ) /* probably need a new font */
+ if ( (code < 129) || (fontbase[font]->spare1 != fontbase[k]->spare1) )
+ CHANGE_FONT(k, last_range);
+
+ if ( code > 128 && fontbase[k]->spare1 ) { /* got some more stuff to do */
+ code = special_case(i, k); /* this is the real APS code for c */
+ last_range = range; /* in case the range was changed */
+ } /* End if */
+
+#ifdef ADJUST
+
+ if ( v_adjust != 0 )
+ vmot(v_adjust);
+
+#endif
+
+ hflush(); /* get to right horizontal position */
+ PUTC(code, tf); /* MACRO - then print the character */
+
+#ifdef ADJUST
+
+ if ( v_adjust != 0 ) {
+ vmot(-v_adjust);
+ v_adjust = 0;
+ } /* End if */
+
+#endif
+
+ if ( (last_range != old_range) || (aps_slant != old_slant) )
+ CHANGE_FONT(old_font, last_range); /* MACRO - back to the old font */
+
+ lastw = ((widthtab[k][i] & BMASK) * pstab[size-1] + dev.unitwidth/2) / dev.unitwidth;
+ htrue += lastw; /* approximate right side of char */
+
+} /* End of put1 */
+
+
+/*****************************************************************************/
+
+
+void
+putint (
+ int n /* write out this integer */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to write the integer n out in the *
+ * last two bytes of a type two command on the APS-5 typesetter. *
+ * *
+ ********************************************************************/
+
+
+
+ PUTC(n >> 8, tf);
+ PUTC(n, tf);
+
+} /* End of putint */
+
+
+/*****************************************************************************/
+
+
+void
+setsize (
+ int n /* new internal size */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to set the current internal size to *
+ * the value n, and then output the commands needed to change the *
+ * APS-5 point size. The internal size n is an index into the *
+ * array pstab[], which contains the actual point size that is to *
+ * be used. *
+ * *
+ * *
+ * NOTE - This routine always calls setfont in case the range *
+ * has changed, but it may be the case that the range doesn't *
+ * really change even though the point size has changed. Always *
+ * making this call definitely produces some unnecessary APS-5 *
+ * code. Probably fix it in setfont routine. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == OFF ) return; /* not doing output on this page */
+
+ if ( n <= 0 || n > nsizes ) { /* internal size out of range */
+ error(FATAL, "illegal internal size %d", n);
+ n = size; /* in case we return from this error */
+ } /* End if */
+
+ size = n; /* must preceed call to setfont() */
+ change_font(font); /* in case the range has changed */
+ PUTC(HVSIZE, tf); /* MACRO - set the new point size */
+ putint(10 * pstab[n-1]); /* APS expects 10 times the size */
+
+} /* End of setsize */
+
+
+/*****************************************************************************/
+
+
+void
+setfont (
+ int n /* new font's internal number */
+)
+
+
+{
+
+
+ int oldrange; /* current master range */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to set the current typesetter font *
+ * to the one that corresponds to the parameter n. These internal *
+ * font numbers are determined by the way the font tables are set *
+ * up for the typesetter in the DESC file. *
+ * *
+ * Our APS-5 typesetter typically has only master ranges 1, 2, *
+ * and 3. The actual font that we want to set is determined by the *
+ * current value of the global variable size. Remember that this *
+ * value is an internal size, which is an index into the array *
+ * pstab[]. The following table gives the point sizes that can be *
+ * used in the different master ranges, *
+ * *
+ * *
+ * MASTER RANGE 1: 0 to 12 *
+ * MASTER RANGE 2: 12 to 24 *
+ * MASTER RANGE 3: 24 to 48 *
+ * MASTER RANGE 4: 48 to 96 *
+ * *
+ * *
+ * although any range can actually print characters up to size, *
+ * *
+ * *
+ * 1.5 * limit - 1 *
+ * *
+ * *
+ * where the value of limit is obtained from the above table. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( output == OFF ) return; /* not doing output for this page */
+
+ if ( n < 0 || n > nfonts ) {
+ error(FATAL, "requested font number %d out of range", n);
+ n = font; /* in case we ignore this error */
+ } /* End if */
+
+ oldrange = range; /* new range may be different */
+ CHANGE_FONT(n, oldrange); /* change the APS font */
+ font = n; /* current internal font number */
+
+} /* End of setfont */
+
+
+/*****************************************************************************/
+
+
+void
+change_font (
+ int n /* new font's internal number */
+)
+
+
+{
+
+
+
+ int angle; /* slant angle - used in SETSLANT */
+ int max_range; /* largest range allowed on font n */
+ int max_size; /* largest size allowed in max_range */
+ char f_spare1; /* value of font flags */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to change the font that the APS is *
+ * currently setting type in. Some extra stuff is done if the font *
+ * has any of its special flags set. *
+ * *
+ ********************************************************************/
+
+
+
+ range = get_range(pstab[size-1]); /* probably the new range */
+
+ f_spare1 = fontbase[n]->spare1; /* get special case font flags */
+ if ( f_spare1 & RANGE_BIT ) { /* have a maximum range for font n */
+
+ max_range = DECODE(f_spare1, RANGE_VAL, TWO_BITS); /* decode this range */
+ if ( range > max_range ) { /* current range is too big */
+ max_size = upper_limit(max_range);
+ if ( size > max_size ) /* can't blow max_range up to size */
+ error(FATAL, "size %d too big for range %d", pstab[size-1], max_range);
+ range = max_range; /* use the biggest possible range */
+ } /* End if */
+
+ } /* End if */
+
+ if ( f_spare1 & SLANT_BIT ) /* this font has a default slant */
+ SETSLANT(f_spare1, angle); /* MACRO - so use it */
+ else if ( aps_slant != last_req_slant ) /* back to the last requested slant */
+ t_slant(last_req_slant);
+
+
+ PUTC(FONT, tf); /* MACRO - set the new font and range */
+ if ( range < 3 ) /* APS expects a positive number */
+ putint(fontname[n].number + range-1);
+ else putint(-(fontname[n].number + range-1));
+
+ aps_font = fontname[n].number; /* font that the APS is using */
+
+} /* End of change_font */
+
+
+/*****************************************************************************/
+
+
+void
+t_fp (
+ int n, /* update this font position */
+ char *s, /* font's external name (eg. R) */
+ char *si /* font number used by the APS */
+)
+
+
+{
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to update the data structures that *
+ * are maintained by the post-processor to keep track of fonts. *
+ * The parameter n is the font position that we are going to *
+ * update, while s and si are the font's external and internal *
+ * names. *
+ * *
+ ********************************************************************/
+
+
+
+ fontname[n].name = s;
+ fontname[n].number = atoi(si);
+ fontname[n].nwfont = fontbase[n]->nwfont;
+
+} /* End of t_fp */
+
+/*****************************************************************************/
+
+void
+getuserid(char *buf, size_t size)
+{
+ struct passwd *pwd;
+
+ if ((pwd = getpwuid(getuid())) != NULL)
+ strncpy(buf, pwd->pw_name, size)[size-1] = '\0';
+}
+
+/*****************************************************************************/
+
+
+void
+account (void)
+
+
+{
+
+
+ char user[100]; /* user's login name */
+ float pages; /* will charge for this many pages */
+
+
+
+ /********************************************************************
+ * *
+ * This is the accounting routine for the post-processor. It *
+ * may have to be changed for your particular system. *
+ * *
+ * NOTE - since the variable res can be changed we better use *
+ * the constant RES to determine how many pages were printed. *
+ * *
+ ********************************************************************/
+
+
+
+ paper = max_vpos; /* used this much paper */
+ pages = paper / (RES * PAGE_LENGTH); /* pages that we think were used */
+
+ if ( x_stat & DO_ACCT ) { /* got accounting to do */
+ getuserid(user, sizeof user);
+ fprintf(fp_acct, " user = %-10s", user);
+ fprintf(fp_acct, " paper = %-10.1f", pages);
+ x_stat &= ~DO_ACCT; /* done the important accounting */
+ fprintf(fp_acct, "exit status = 0%-6o", x_stat);
+ if ( tf == stdout )
+ fprintf(fp_acct, " ??");
+ fprintf(fp_acct, "\n");
+ } /* End if */
+
+ if ( report == YES )
+ fprintf(stderr, " %-3.1f pages\n", pages);
+
+} /* End of account */
+
+
+/*****************************************************************************/
+
+
+int
+special_case (
+ int index, /* char position in tables */
+ int font /* char info is on this font */
+)
+
+
+{
+
+
+ int old_range; /* saved value of current range */
+ int old_font; /* present APS-5 font number */
+ int req_font; /* requested APS-5 font number */
+ int max_range; /* max allowed range for character */
+ int max_size; /* max size allowed for max_range */
+ int angle; /* special char angle to set */
+ int code; /* old code - with bits set */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called by put1() to handle the special any *
+ * special case characters for the APS-5. *
+ * *
+ * Taken on its own, this is a very confusing routine, but one *
+ * which I found from my experience with the APS-5 at Murray Hill *
+ * was definitely needed. I'll try to give a brief, but hopefully *
+ * complete explination here. *
+ * *
+ * The additions that I made here needed to be completely *
+ * transparent to troff, and so the only field in the font tables *
+ * that could be changed was the actual charater code, since troff *
+ * can't possibly need this stuff (it's device independent!). On *
+ * the APS-5, character codes lie between 1 and 128 (inclusive) - *
+ * anything else is an actual function code. Therefore when we are *
+ * ready to print a character in put1(), and we find that its code *
+ * is larger than 128 we know something more has to be done. This *
+ * routine is then called to try to make sense out of the code, *
+ * do any of the special stuff required for this character, and *
+ * finially return its real code. This extra stuff can include *
+ * changing the character's slant, ensuring that the current *
+ * master range is not larger than a given value (max_range), and *
+ * finially getting the actual character from a completely *
+ * different font (alternate_font). What we actually do for each *
+ * special character is determined by its code in the current *
+ * set of font tables. This code is produced by a special version *
+ * of the makedev program, which I changed to interpret some *
+ * extra fields in the ASCII font tables. *
+ * *
+ * *
+ * NOTE - This extra stuff is costly, and should only be used *
+ * when absolutely necessary. The alternate font stuff can *
+ * cause many extra font changes, which in turn will force extra *
+ * disk accesses. We found this to be one of the main reasons for *
+ * slow jobs on our APS, not to mention the extra wear on the disk *
+ * drive. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( fontname[font].number != alt_tables ) /* don't have font's table */
+ load_alt(font); /* load font's '.add' tables */
+
+ code = codetab[font][index] & BMASK; /* encoded character information */
+ old_range = range; /* current typesetter range */
+ old_font = aps_font; /* quick change - fix it later */
+ req_font = old_font;
+
+ if ( code & SLANT_BIT ) /* special slant for this character */
+ SETSLANT(code, angle); /* MACRO - set slant to encoded value */
+
+ if ( code & RANGE_BIT ) { /* maximum range specified */
+
+ max_range = DECODE(code, RANGE_VAL, TWO_BITS);
+ range = get_range(pstab[size-1]); /* get range for current size */
+ if ( range > max_range ) { /* check current size first */
+ max_size = upper_limit(max_range);
+ if ( size > max_size ) /* too big for max_range - abort */
+ error(FATAL, "size %d too large for range %d", pstab[size-1], max_range);
+ else range = max_range; /* set the range */
+ } /* End if */
+
+ } /* End if */
+
+ if ( code & FONT_BIT ) /* alternate font specified */
+ req_font = alt_font[index]; /* APS-5 alternate font number */
+
+ if ( (old_range != range) || (req_font != old_font) ) {
+
+ aps_font = req_font;
+ PUTC(FONT, tf); /* set new font */
+ if ( range < 3 ) /* output positive number */
+ putint(req_font + range - 1);
+ else putint(-(req_font + range - 1));
+ if ( range != old_range ) { /* Need to set the size */
+ PUTC(HVSIZE, tf); /* MACRO - set the point size */
+ putint(10 * pstab[size-1]);
+ } /* End if */
+
+ } /* End if */
+
+ return(alt_code[index] & BMASK);
+
+} /* End of special_case */
+
+
+/*****************************************************************************/
+
+
+int
+get_range (
+ int n /* find the range for this point size */
+)
+
+
+{
+
+
+ int val; /* return this as the range */
+ int msize; /* size for master range val */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to return the range corresponding to *
+ * the point size n. Note that n is not an internal size for this *
+ * routine. *
+ * *
+ ********************************************************************/
+
+
+
+ val = 0;
+
+ while ( ++val <= MAX_RANGE ) {
+ msize = BASE_SIZE(val); /* base size for master range val */
+ if ( (val == MAX_RANGE) && (val <= 3) ) /* scale it up */
+ msize = SCALE_UP(msize);
+ if ( n <= msize ) return(val); /* found the correct master range */
+ } /* End while */
+
+ error(FATAL, "size %d too large", n);
+ return(1); /* in case we ignore this error */
+
+} /* End of get_range */
+
+
+/*****************************************************************************/
+
+
+void
+fileinit (void)
+
+
+{
+
+
+ int fin; /* input file descriptor */
+ int nw; /* number of font table entries */
+ int i; /* for loop index */
+ char *filebase; /* pointer to memory block */
+ char *p; /* pointer used to set up tables */
+ char temp[60]; /* pathname of the DESC.out file */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is responsible for reading the DESC.out file *
+ * for the APS-5 typesetter, and then initializing the appropriate *
+ * data structures for the device and all of the default fonts *
+ * that were mentioned in the typesetter description file DESC. *
+ * *
+ * First the DESC.out file is opened and the structure dev is *
+ * initialized from the first part of the file. This structure *
+ * then contains all the information needed to enable us to finish *
+ * the initialization process. Next the rest of the file is read *
+ * in and the device tables pstab[], chtab[], and chname[] are set *
+ * up. After this has been done we enter a loop which handles the *
+ * initialization for all of the fonts that were mentioned in the *
+ * DESC file. Finially we allocate enough memory so that font *
+ * position 0 can be loaded with the tables from any valid font *
+ * in the library. *
+ * *
+ * *
+ * NOTE - the program 'makedev' creates all of the '.out' *
+ * files in the troff font library. This routine quite obviously *
+ * depends on how 'makedev' has written these files. In addition *
+ * the troff program also reads the '.out' files and it too *
+ * expects the same format as we do here! To really understand *
+ * this routine you need to look at 'makedev.c' and the ASCII *
+ * tables in the troff font library. *
+ * *
+ ********************************************************************/
+
+
+
+ sprintf(temp, "%s/dev%s/DESC.out", fontdir, devname);
+ if ( (fin = open(temp, O_RDONLY)) < 0 ) /* file didn't open - abort */
+ error(FATAL, "can't open tables for %s", temp);
+
+ READ(fin, &dev, sizeof(struct dev)); /* init dev structure */
+
+ nsizes = dev.nsizes; /* number of point sizes specified */
+ nchtab = dev.nchtab; /* number of char table entries */
+ nfonts = dev.nfonts; /* number of default fonts */
+
+ if ( nfonts > NFONT ) /* need to redefine NFONT */
+ error(FATAL, "internal error - constant NFONT too small");
+
+ filebase = malloc(dev.filesize); /* space for rest of the file */
+ READ(fin, filebase, dev.filesize); /* read in the rest of the file */
+
+ pstab = (short *) filebase; /* point size list is first */
+ chtab = pstab + nsizes + 1; /* next comes chtab list */
+ chname = (char *) (chtab + dev.nchtab); /* then the char table list */
+
+ p = chname + dev.lchname; /* start of font table info */
+
+ for (i = 1; i <= nfonts; i++) { /* set up default font tables */
+
+ fontbase[i] = (struct Font *) p;
+ nw = *p & BMASK; /* width count comes first */
+
+ if (smnt == 0 && fontbase[i]->specfont == 1)
+ smnt = i; /* this is first special font */
+
+ p += sizeof(struct Font); /* font structure was written first */
+ widthtab[i] = p; /* next is this font's width table */
+ codetab[i] = p + 2 * nw; /* skip kern to get the code table */
+ fitab[i] = p + 3 * nw; /* last is the font index table */
+
+ p += 3 * nw + dev.nchtab + 128 - 32; /* point to next font */
+
+ t_fp(i, fontbase[i]->namefont, fontbase[i]->intname);
+
+ if ( debug[5] ) fontprint(i); /* dump font tables */
+
+ } /* End for */
+
+ if ( smnt == 0 ) /* no special fonts specified */
+ smnt = nfonts + 1; /* used in routine put1() */
+
+ fontbase[0] = (struct Font *) malloc(3*255 + dev.nchtab + (128-32) + sizeof(struct Font));
+ widthtab[0] = (char *) fontbase[0] + sizeof(struct Font);
+ fontbase[0]->nwfont = 255;
+ close(fin);
+
+} /* End of fileinit */
+
+
+/*****************************************************************************/
+
+
+void
+fontprint (
+ int i /* index of font to print out */
+)
+
+
+{
+
+
+ int j; /* for loop variable */
+ int n; /* number of width entries */
+ int pos; /* position of char from fitab array */
+ int count; /* count of characters in this font */
+
+
+
+ /********************************************************************
+ * *
+ * This is a debugging routine that is used to dump all of the *
+ * information about font i that was loaded from the '.out' file. *
+ * It is called from fileinit() when the debug flag 5 is turned *
+ * on, and from loadfont when flag 6 is set. *
+ * *
+ ********************************************************************/
+
+
+
+ n = fontbase[i]->nwfont & BMASK; /* number of width entries */
+
+ fprintf(fp_debug, "\nDUMP FOR FONT %s ", fontbase[i]->namefont);
+ fprintf(fp_debug, " FONT POSITION = %d\n\n", i);
+ fprintf(fp_debug, " font structure data:\n");
+ fprintf(fp_debug, "\t\tfont.nwfont = %d\n", fontbase[i]->nwfont & BMASK);
+ fprintf(fp_debug, "\t\tfont.specfont = %d\n", fontbase[i]->specfont & BMASK);
+ fprintf(fp_debug, "\t\tfont.ligfont = %d\n", fontbase[i]->ligfont & BMASK);
+ fprintf(fp_debug, "\t\tfont.spare1 = %d\n", fontbase[i]->spare1 & BMASK);
+ fprintf(fp_debug, "\t\tfont.intname = %s\n\n", fontbase[i]->intname);
+
+ fprintf(fp_debug, " CHAR WIDTH CODE INDEX\n");
+ count = 0;
+
+ for (j = 0; j < dev.nchtab + 128 - 32; j++) {
+
+ if ( (pos = fitab[i][j] & BMASK) != 0 ) {
+ count++;
+ if ( j >= 96 ) /* special chars start at 128-32 */
+ fprintf(fp_debug, "%5s", &chname[chtab[j-96]]);
+ else fprintf(fp_debug, "%5c", (j + 32) & BMASK);
+ fprintf(fp_debug, "%10d", widthtab[i][pos] & BMASK);
+ fprintf(fp_debug, "%10d", codetab[i][pos] & BMASK);
+ fprintf(fp_debug, "%10d", j);
+ if ( alt_tables == fontname[i].number ) /* print extra info */
+ fprintf(fp_debug, "%10d%10d", alt_code[pos] & BMASK, alt_font[pos]);
+ fprintf(fp_debug,"\n");
+ } /* End if */
+
+ } /* End for */
+
+ fprintf(fp_debug, "\n CHARACTER COUNT FOR THIS FONT = %d\n", count);
+ fprintf(fp_debug, "\n\n");
+
+} /* End of fontprint */
+
+
+/*****************************************************************************/
+
+
+void
+loadfont (
+ int num, /* font position to load */
+ char *name, /* name of the font to load */
+ char *fdir /* name of directory to load from? */
+)
+
+
+{
+
+
+ int fin; /* font file descriptor */
+ int nw; /* width entries in new font file */
+ int norig; /* width entries in old font file */
+ char temp[60]; /* path name of font file */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to load the font position num with *
+ * the data for the font name. If the string fdir is not null then *
+ * it is taken as the pathname of the directory that contains the *
+ * '.out' file for the font that we are to load, otherwise we load *
+ * this data from the standard font library. *
+ * *
+ ********************************************************************/
+
+
+
+ if ( num < 0 || num > NFONT ) /* illegal font number - abort */
+ error(FATAL, "illegal fp command %d %s", num, name);
+
+ if ( strcmp(name, fontbase[num]->namefont) == SAME_STR ) /* in already */
+ return;
+
+ if ( fdir == NULL || fdir[0] == '\0' ) /* no alternate directory */
+ sprintf(temp, "%s/dev%s/%s.out", fontdir, devname, name);
+ else sprintf(temp, "%s/%s.out", fdir, name);
+
+ if ( (fin = open(temp, O_RDONLY)) < 0 ) /* open the font file */
+ error(FATAL, "can't open font table %s", temp);
+
+ norig = fontbase[num]->nwfont & BMASK; /* 'space' available in pos num */
+ READ(fin, fontbase[num], 3*norig + nchtab+128-32 + sizeof(struct Font));
+ nw = fontbase[num]->nwfont & BMASK; /* 'space' needed for new font */
+ if ( nw > norig ) /* new font is too big - abort */
+ error(FATAL, "font %s too big for position %d", name, num);
+
+ close(fin);
+ widthtab[num] = (char *) fontbase[num] + sizeof(struct Font);
+ codetab[num] = (char *) widthtab[num] + 2 * nw;
+ fitab[num] = (char *) widthtab[num] + 3 * nw;
+ t_fp(num, fontbase[num]->namefont, fontbase[num]->intname);
+
+ fontbase[num]->nwfont = norig; /* save size of position num */
+
+ if ( debug[6] ) fontprint(num); /* dump font position num */
+
+} /* End of loadfont */
+
+
+/*****************************************************************************/
+
+
+void
+load_alt (
+ int font /* load '.add' tables for this font */
+)
+
+
+{
+
+
+ int nw; /* number of width entries for font */
+ int fin; /* font file descriptor */
+ char cmd[60]; /* room for font's .add file */
+
+
+
+ /********************************************************************
+ * *
+ * This routine is called to read in the '.add' file for the *
+ * font that is loaded in the position specified by the parameter *
+ * font. These '.add' files are created by the special version of *
+ * the makedev program, which reads and interprets several extra *
+ * fields in the APS font tables. Included in the '.add' files are *
+ * the alternate font table and the APS-5 character code table. *
+ * *
+ ********************************************************************/
+
+
+
+ sprintf(cmd, "%s/dev%s/%s.add", fontdir, devname, fontname[font].name);
+
+ if ( (fin = open(cmd, O_RDONLY)) < 0 ) /* couldn't open the file */
+ error(FATAL, "can't open file %s", cmd);
+
+ nw = fontname[font].nwfont & BMASK; /* number of width entries */
+
+ READ(fin, alt_font, nw * sizeof(alt_font[0]));
+ READ(fin, alt_code, nw); /* read alternate code table */
+
+ close(fin);
+ alt_tables = fontname[font].number; /* read in tables for this font */
+
+ if ( debug[7] ) /* print all the font information */
+ fontprint(font);
+
+} /* End of load_alt */
+
+
+/*****************************************************************************/
diff --git a/troff/troff.d/devaps/daps.g b/troff/troff.d/devaps/daps.g
new file mode 100644
index 000000000000..fec013575a18
--- /dev/null
+++ b/troff/troff.d/devaps/daps.g
@@ -0,0 +1,219 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* from OpenSolaris "daps.g 1.4 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)daps.g 1.4 (gritter) 8/13/05
+ */
+
+/*
+ * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+
+ /********************************************************************
+ * *
+ * POST-PROCESSOR GLOBAL VARIABLES *
+ * *
+ ********************************************************************/
+
+
+
+short debug[MAX_DEBUG]; /* array of debug flags */
+
+short privelege = ON; /* is user priveleged */
+
+short x_stat = 0; /* program exits with this status */
+
+short ignore = NO; /* don't ignore fatal errors */
+short report = NO; /* just report results */
+short busyflag = OFF; /* report typesetter availability */
+short waitflag = OFF; /* wait for typesetter */
+
+short output = OFF; /* ON if we do output for this page */
+
+int nolist = 0; /* number of page pairs in olist[] */
+
+int olist[MAX_OUTLIST]; /* list of pages to process */
+
+int spage = 9999; /* stop every spage pages */
+
+int scount = 0; /* spage counter */
+
+int arg_index = 0; /* offset from argv for next argument */
+
+long line_number = -1; /* current line in input file */
+
+int lastw; /* width of last printed character */
+
+int pageno = 0; /* current page number */
+long paper = 0; /* amount of paper used */
+
+char *banner = "\0"; /* pointer to banner string */
+char ban_buf[BAN_LENGTH]; /* buffer for banner read from file */
+short print_banner = NO; /* print the job's banner? */
+char *cut_marks = "--"; /* string used for cut marks */
+char *ban_sep = "\\(en \\(en \\(en \\(en \\(en \\(en \\(en \\(en \\(en \\(en";
+
+short last_slant = 0; /* last slant stored in the APS-5 */
+short last_req_slant = 0; /* last requested slant from troff */
+short aps_slant = 0; /* current slant angle for type */
+int aps_font = 0; /* font that the APS is using */
+
+short range = 1; /* current master range */
+
+
+#define devname troff_devname
+char devname[NAME_LENGTH] = "aps"; /* name of phototypesetter */
+
+char *typesetter = "/dev/null"; /* should be /dev/aps */
+char *tracct = ""; /* accounting file pathname */
+char *fontdir = FNTDIR; /* font directory */
+
+int alt_tables = 0; /* which font has alt tables loaded */
+int alt_font[FSIZE]; /* alternate font table */
+char alt_code[FSIZE]; /* alternate code table */
+
+short *pstab; /* point size list */
+short *chtab; /* char's index in chname array */
+char *chname; /* special character strings */
+char *fitab[NFONT+1]; /* chars position on a font */
+char *widthtab[NFONT+1]; /* character's width on a font */
+char *codetab[NFONT+1]; /* APS-5 code for character */
+
+int nsizes; /* number of sizes from DESC.out */
+int nfonts; /* number of default fonts */
+int nchtab; /* number of special chars in chtab */
+int smnt = 0; /* index of first special font */
+int res = 723; /* DESC.out res should equal this */
+
+int size = 1; /* current internal point size */
+int font = 1; /* current font number */
+
+int hpos; /* troff calculated horiz position */
+int htrue = 0; /* our calculated horiz position */
+int vpos; /* current vertical position (down positive) */
+int hcutoff = HCUTOFF; /* horizontal cutoff in device units */
+double cutoff = CUTOFF; /* horizontal beam cutoff in inches */
+long cur_vpos = 0; /* current distance from start of job */
+long max_vpos = 0; /* maximum distance from start of job */
+
+
+int DX = 3; /* step size in x for drawing */
+int DY = 3; /* step size in y for drawing */
+int drawdot = '.'; /* draw with this character */
+int drawsize = 1; /* shrink by this factor when drawing */
+
+
+struct { /* font position information */
+ char *name; /* external font name */
+ int number; /* internal font name */
+ int nwfont; /* width entries - load_alt uses it */
+} fontname[NFONT+1];
+
+struct dev dev; /* store APS data here from DESC.out */
+
+struct Font *fontbase[NFONT+1]; /* point to font data from DESC.out */
+
+
+FILE *fp_debug; /* debug file descriptor */
+FILE *fp_error; /* error message file descriptor */
+FILE *fp_acct; /* accounting file descriptor */
+FILE *tf; /* typesetter output file */
+
+int horig; /* not really used */
+int vorig;
+
+int vert_step = MAX_INT; /* break up vert steps larger than this */
+
+
+
+/*****************************************************************************/
+
+
+
+#ifdef ADJUST /* do the vertical adjustments */
+
+
+
+ /********************************************************************
+ * *
+ * Some of the characters on the current APS disk at Murray *
+ * Hill are quite bad. In particular lf, rf, lb, and rb are all *
+ * too low, so that braces built up from them don't join properly. *
+ * The data structures that follow are used to make the proper *
+ * vertical adjustment for problem characters such as these. They *
+ * are only used in routines put1s() and put1(). The code in these *
+ * two routines that was added to handle these special cases *
+ * should be removed or commented out when the characters are *
+ * finially fixed! In addition routine t_adjust() was written *
+ * to do the lookup in these tables and set the appropriate value *
+ * for v_adjust - it can be removed whenever you no longer need *
+ * these vertical adjustments. *
+ * *
+ * All of this vertical adjustment stuff is included in the *
+ * object code when the conditional compilation flag ADJUST is *
+ * defined. To eliminate the overhead of these adjustments just *
+ * remove the definition of ADJUST from daps.h. *
+ * *
+ ********************************************************************/
+
+
+
+int v_adjust = 0; /* vert adjustment - done in put1() */
+
+char *adj_tbl[] = { /* adjust these characters */
+ "lf",
+ "rf",
+ "lb",
+ "rb",
+ "lt",
+ "rt",
+ 0,
+};
+
+int vadjustment[] = { /* corresponding vert adjustment */
+ -1,
+ -1,
+ -3,
+ -3,
+ 1,
+ 1,
+ 0,
+};
+
+
+#endif
+
diff --git a/troff/troff.d/devaps/daps.h b/troff/troff.d/devaps/daps.h
new file mode 100644
index 000000000000..0f0ebae1cec1
--- /dev/null
+++ b/troff/troff.d/devaps/daps.h
@@ -0,0 +1,461 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "daps.h 1.5 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)daps.h 1.3 (gritter) 8/9/05
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+
+
+
+ /********************************************************************
+ * *
+ * The following defined constants and macros must be properly *
+ * set up for your APS-5 photo-typesetter. *
+ * *
+ ********************************************************************/
+
+
+
+#define ADJUST 1 /* conditional compilation flag */
+
+#define LENS3 1 /* used for conditional compilation */
+#define MAX_RANGE 3 /* largest master range on this APS-5 */
+
+
+
+#ifdef LENS1 /* standard 2.22X lens */
+
+#define RANGE1_SIZE 10 /* used in macro BASE_SIZE */
+#define SCALEFACTOR 1.25 /* can scale lower ranges up this far */
+
+
+#define BASE_SIZE(Range) /* base size for master range Range */ \
+ \
+ (RANGE1_SIZE * (1 << (Range - 1)))
+
+
+#define SCALE_UP(Bsize) /* max size for lower ranges */ \
+ \
+ (Bsize * SCALEFACTOR)
+
+#endif
+
+
+
+#ifdef LENS2 /* standard 2.667X lens */
+
+#define RANGE1_SIZE 12 /* master range 1 base size */
+#define SCALEFACTOR 1.25 /* can scale lower ranges up this far */
+
+
+#define BASE_SIZE(Range) /* base size for master range Range */ \
+ \
+ (RANGE1_SIZE * (1 << (Range - 1)))
+
+
+#define SCALE_UP(Bsize) /* max size for lower ranges */ \
+ \
+ (Bsize * SCALEFACTOR)
+
+#endif
+
+
+#ifdef LENS3 /* 2.667X lens - special case */
+
+#define RANGE1_SIZE 12 /* master range 1 base size */
+#define SCALEFACTOR 1.50 /* can scale lower ranges up this far */
+
+
+#define BASE_SIZE(Range) /* base size for master range Range */ \
+ \
+ (RANGE1_SIZE * (1 << (Range - 1)))
+
+
+#define SCALE_UP(Bsize) /* max size for lower ranges */ \
+ \
+ (Bsize * SCALEFACTOR - 1)
+
+#endif
+
+
+
+
+ /********************************************************************
+ * *
+ * POST-PROCESSOR DEFINED CONSTANTS *
+ * *
+ ********************************************************************/
+
+
+
+#define NON_FATAL 0 /* don't abort the job */
+#define FATAL 1 /* fatal error - abort the job */
+#define OFF 0 /* debug mode is off */
+#define ON 1 /* debug mode is on */
+#define NO 0 /* don't ignore fatal errors - debug */
+#define YES 1 /* ignore fatal errors - debug only! */
+#define SAME_STR 0 /* strings are the same */
+
+#define RES 723.0 /* use this constant for accounting! */
+#define PAGE_LENGTH 11.0 /* inches per page for accounting */
+
+#define CUTOFF 10.0 /* beam cutoff position (inches) */
+#define HCUTOFF 7230 /* beam cutoff in device units */
+
+
+#define BMASK 0377 /* used for character mask */
+
+#define MAX_INT 30000 /* used in t_reset() */
+#define MAX_DEBUG 20 /* number of debug states */
+
+#define MAX_OUTLIST 30 /* number of page pairs olist array */
+
+#define NAME_LENGTH 10 /* max length of typesetter name */
+
+#define FSIZE 200 /* size of a physical font */
+
+#define SLOP 2 /* error factor used in hflush() */
+
+#define NFONT 10 /* number of font positions available */
+
+#define POS_SLANT 14 /* angle used for positive slants */
+#define NEG_SLANT -14 /* angle used for negative slants */
+
+#define TWO_BITS 3 /* mask for two rightmost bits */
+
+#define BIT0 1 /* mask for bit 0 */
+#define BIT1 2 /* mask for bit 1 */
+#define BIT2 4 /* mask for bit 2 */
+#define BIT3 8 /* mask for bit 3 */
+
+#define SLANT_BIT BIT0 /* slant bit is bit 0 */
+#define FONT_BIT BIT1 /* alternate font is bit 1 */
+#define RANGE_BIT BIT2 /* max range is bit 2 */
+
+#define SLANT_VAL 3 /* slant angle starts in bit 3 */
+#define RANGE_VAL 5 /* range value starts in bit 5 */
+
+#define DO_ACCT BIT0 /* still have to do accounting if on */
+#define FILE_STARTED BIT1 /* file started but not completed */
+#define NO_OUTFILE BIT2 /* no output file if on */
+#define NO_ACCTFILE BIT3 /* no accounting file if on */
+
+#define BAN_LENGTH 130 /* max length of banner string */
+#define BAN_SIZE 10 /* point size to use in banner */
+
+#define VSPACE0 6 /* space down for first cut marks */
+#define VSPACE1 180 /* space at start of banner */
+#define VSPACE2 180 /* space before printing user string */
+#define VSPACE3 180 /* space before printing separator */
+#define VSPACE4 180 /* space before starting user job */
+
+#define HSPACE0 5346 /* space right for second cut marks */
+#define HSPACE1 50 /* indent before first separator */
+#define HSPACE2 100 /* indent before user string */
+#define HSPACE3 50 /* indent before second separator */
+#define HSPACE4 0 /* start cut marks at this position */
+
+
+
+
+ /********************************************************************
+ * *
+ * POST-PROCESSOR MACROS *
+ * *
+ ********************************************************************/
+
+
+
+
+#define SET_ARGS(save) /* set up internal argc and argv */ \
+ \
+ save = argc; /* save current value of argc */ \
+ argc -= arg_index; /* count arguments read already */ \
+ argv += arg_index
+
+
+
+
+#define COUNT_ARGS(save) /* count the arguments processed */ \
+ \
+ arg_index = save - argc /* arg_index counts the arguments */
+
+
+
+
+#define STR_CONVERT(s,i) /* convert string s to integer i */ \
+ \
+ do { \
+ i = 0; \
+ do \
+ i = 10 * i + *s++ - '0'; \
+ while ( isdigit(*s) ); \
+ } while ( 0 )
+
+
+
+
+#define TOGGLE(a) /* toggle the value in argument a */ \
+ \
+ a = (a + 1) % 2
+
+
+
+
+#define GET_DIG(fp,c) /* get a single ASCII digit */ \
+ \
+ c = getc(fp); \
+ if ( !isdigit(c) || c == EOF ) /* illegal character */ \
+ error(FATAL, "internal error - digit not found in GET_DIG")
+
+
+
+
+#define GET_CHAR(fp,c) /* get a single ASCII character */ \
+ \
+ if ( (c = getc(fp)) == EOF ) /* end of file - abort */ \
+ error(FATAL, "internal error - char not found in GET_CHAR")
+
+
+
+
+#define GET_INT(fp,n) /* get an integer from file fp */ \
+ \
+ if ( fscanf(fp, "%d", &n) != 1 ) /* end of file - abort */ \
+ error(FATAL,"internal error - integer not found in GET_INT")
+
+
+
+
+#define GET_STR(fp,str) /* get a string from file fp */ \
+ \
+ if ( fscanf(fp, "%s", str) != 1 ) /* end of file - abort */ \
+ error(FATAL, "internal error - string not found in GET_STR")
+
+
+
+
+#define GET_LINE(fp,buf) /* read a line from file fp into buf */ \
+ \
+ if ( fgets(buf, sizeof(buf), fp) == NULL ) \
+ error(FATAL, "internal error - line not found in GET_LINE")
+
+
+
+
+#define SKIP_LINE(fp,c) /* skip to the next line of the file fp */ \
+ \
+ while ( ((c = getc(fp)) != '\n') && c != EOF ) \
+ ;
+
+
+
+
+#define SCAN1(buf,n1) /* read one number from buf */ \
+ \
+ if ( sscanf(buf, "%d", &n1) != 1 ) \
+ error(FATAL, "internal error - integer not found in SCAN1")
+
+
+
+
+#define SCAN2(buf,n1,n2) /* read two numbers from buf */ \
+ \
+ if ( sscanf(buf, "%d %d", &n1, &n2) != 2 ) \
+ error(FATAL, "internal error - integers not found in SCAN2")
+
+
+
+
+#define SCAN3(buf,n1,n2,n3) /* read three numbers from buf */ \
+ \
+ if ( sscanf(buf, "%d %d %d", &n1, &n2, &n3) != 3 ) \
+ error(FATAL, "internal error - integers not found in SCAN3")
+
+
+
+
+#define SCAN4(buf,n1,n2,n3,n4) /* read four numbers from buf */ \
+ \
+ if ( sscanf(buf, "%d %d %d %d", &n1, &n2, &n3, &n4) != 4 ) \
+ error(FATAL, "internal error - integers not found in SCAN4")
+
+
+
+
+#define SCAN_STR(buf,str) /* read a string from buf */ \
+ \
+ sscanf(buf, "%s", str)
+
+
+
+
+#ifdef pdp11 /* sign extension problems on pdp11s */
+
+#define PUTC(ch, fp) /* don't check for error if ch = 0377 */ \
+ \
+ if ( (putc(ch, fp) == EOF) && ((ch & BMASK) != 0377) ) \
+ error(FATAL, "internal error - PUTC can't output character")
+
+#else /* don't worry about char 0377 */
+
+#define PUTC(ch, fp) /* write character ch to file fp */ \
+ \
+ if ( putc(ch, fp) == EOF ) /* error in writing to fp */ \
+ error(FATAL, "internal error - PUTC can't output character")
+
+#endif
+
+
+
+
+#define READ(fd, buf, n) /* read n chars from file fd into buf */ \
+ \
+ if ( read(fd, buf, n) < 0 ) /* error in reading from fd */ \
+ error(FATAL, "internal error - READ can't read input file")
+
+
+
+
+#define DECODE(value, start, bitmask) \
+ \
+ (value >> start) & bitmask
+
+
+
+
+#define CHANGE_FONT(newfont, oldrange) /* set font to newfont */ \
+ \
+ do { \
+ change_font(newfont); \
+ if ( oldrange != range ) { /* range has changed */ \
+ PUTC(HVSIZE, tf); /* so set the point size */ \
+ putint(10*pstab[size-1]); /* to current size */ \
+ oldrange = range; \
+ } /* End if */ \
+ } while ( 0 )
+
+
+
+
+#define SETSLANT(code, angle) /* set slant to value encoded in code */ \
+ \
+ do { \
+ angle = DECODE(code, SLANT_VAL, TWO_BITS); \
+ if ( angle & BIT0 ) /* have positive APS-5 slant */ \
+ angle = POS_SLANT; \
+ else if ( angle & BIT1 ) /* have negative slant */ \
+ angle = NEG_SLANT; \
+ t_slant(angle + last_req_slant); /* set the correct slant */ \
+ } while ( 0 )
+
+
+
+
+/* build.c */
+int newfile(char *, int);
+FILE *charfile(char *, int);
+void save_env(void);
+void restore_env(void);
+void nconv(FILE *);
+/* daps.c */
+void get_options(int, char *[]);
+void process_input(int, char *[]);
+void init_signals(void);
+void debug_select(char *);
+void debug_file(char *);
+void log_file(char *);
+void acct_file(void);
+void ban_file(char *);
+void out_file(void);
+void outlist(char *);
+void error(int, char *, ...);
+int done(void);
+void float_err(int);
+void wrap_up(int);
+void conv(register FILE *);
+void drawfunct(char [], FILE *);
+void devcntrl(FILE *);
+void t_init(void);
+void t_banner(void);
+void t_page(int);
+void t_newline(void);
+int t_size(int);
+void t_charht(int);
+int upper_limit(int);
+void t_slant(int);
+int t_font(char *);
+void t_text(char *);
+void t_reset(int);
+void hflush(void);
+void hmot(int);
+void hgoto(int);
+void vgoto(int);
+void vmot(int);
+void put1s(char *);
+void t_adjust(char *);
+void put1(int);
+void putint(int);
+void setsize(int);
+void setfont(int);
+void change_font(int);
+void t_fp(int, char *, char *);
+void account(void);
+int special_case(int, int);
+int get_range(int);
+void fileinit(void);
+void fontprint(int);
+void loadfont(int, char *, char *);
+void load_alt(int);
+/* ../draw.c */
+void drawline(int, int, char *);
+void drawwig(char *);
+char *getstr(char *, char *);
+void drawcirc(int);
+int dist(int, int, int, int);
+void drawarc(int, int, int, int);
+void drawellip(int, int);
+void conicarc(int, int, int, int, int, int, int, int);
+void putdot(int, int);
diff --git a/troff/troff.d/devaps/dev.h b/troff/troff.d/devaps/dev.h
new file mode 100644
index 000000000000..14e838de3a45
--- /dev/null
+++ b/troff/troff.d/devaps/dev.h
@@ -0,0 +1,81 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+/* from OpenSolaris "dev.h 1.6 05/06/08 SMI" SVr4.0 1.1 */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)dev.h 1.3 (gritter) 8/9/05
+ */
+
+/*
+ dev.h: characteristics of a typesetter
+*/
+
+struct dev {
+ unsigned short filesize; /* number of bytes in file, */
+ /* excluding dev part */
+ short res; /* basic resolution in goobies/inch */
+ short hor; /* goobies horizontally */
+ short vert;
+ short unitwidth; /* size at which widths are given, in effect */
+ short nfonts; /* number of fonts physically available */
+ short nsizes; /* number of sizes it has */
+ short sizescale; /* scaling for fractional point sizes */
+ short paperwidth; /* max line length in units */
+ short paperlength; /* max paper length in units */
+ short nchtab; /* number of funny names in chtab */
+ short lchname; /* length of chname table */
+ short biggestfont; /* #chars in largest ever font */
+ short spare2; /* in case of expansion */
+};
+
+struct Font { /* characteristics of a font */
+ char nwfont; /* number of width entries for this font */
+ char specfont; /* 1 == special font */
+ char ligfont; /* 1 == ligatures exist on this font */
+ char spare1; /* unused for now */
+ char namefont[10]; /* name of this font (e.g., "R" */
+ char intname[10]; /* internal name (=number) on device, in ascii */
+};
+
+/* ligatures, ORed into ligfont */
+
+#define LFF 01
+#define LFI 02
+#define LFL 04
+#define LFFI 010
+#define LFFL 020
diff --git a/troff/troff.d/devaps/draw.c b/troff/troff.d/devaps/draw.c
new file mode 100644
index 000000000000..af39589bd111
--- /dev/null
+++ b/troff/troff.d/devaps/draw.c
@@ -0,0 +1,3 @@
+/* Sccsid @(#)draw.c 1.1 (gritter) 7/3/06 */
+
+#include "../draw.c"
diff --git a/troff/troff.d/devaps/getopt.c b/troff/troff.d/devaps/getopt.c
new file mode 100644
index 000000000000..bb8c53d072cb
--- /dev/null
+++ b/troff/troff.d/devaps/getopt.c
@@ -0,0 +1,222 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)getopt.c 1.10 (gritter) 12/16/07
+ */
+/* from OpenSolaris "getopt.c 1.23 05/06/08 SMI" */
+
+/* Copyright (c) 1988 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * See getopt(3C) and SUS/XPG getopt() for function definition and
+ * requirements.
+ *
+ * This actual implementation is a bit looser than the specification
+ * as it allows any character other than ':' to be used as an option
+ * character - The specification only guarantees the alnum characters
+ * ([a-z][A-Z][0-9]).
+ */
+
+#include <sys/types.h>
+#include <string.h>
+#include <stdio.h>
+
+extern ssize_t write(int, const void *, size_t);
+
+char *optarg = NULL;
+int optind = 1;
+int opterr = 1;
+int optopt = 0;
+
+#define ERR(s, c) err(s, c, optstring, argv[0])
+static void
+err(const char *s, int c, const char *optstring, const char *argv0)
+{
+ char errbuf[256], *ep = errbuf;
+ const char *cp;
+
+ if (opterr && optstring[0] != ':') {
+ for (cp = argv0; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
+ *ep = *cp;
+ for (cp = ": "; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
+ *ep = *cp;
+ for (cp = s; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
+ *ep = *cp;
+ for (cp = " -- "; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
+ *ep = *cp;
+ if (ep<&errbuf[sizeof errbuf])
+ *ep++ = c;
+ if (ep<&errbuf[sizeof errbuf])
+ *ep++ = '\n';
+ write(2, errbuf, ep - errbuf);
+ }
+}
+
+/*
+ * getopt_sp is required to keep state between successive calls to getopt()
+ * while extracting aggregated options (ie: -abcd). Hence, getopt() is not
+ * thread safe or reentrant, but it really doesn't matter.
+ *
+ * So, why isn't this "static" you ask? Because the historical Bourne
+ * shell has actually latched on to this little piece of private data.
+ */
+int getopt_sp = 1;
+
+/*
+ * Determine if the specified character (c) is present in the string
+ * (optstring) as a regular, single character option. If the option is found,
+ * return a pointer into optstring pointing at the option character,
+ * otherwise return null. The character ':' is not allowed.
+ */
+static char *
+parse(const char *optstring, const char c)
+{
+ char *cp = (char *)optstring;
+
+ if (c == ':')
+ return (NULL);
+ do {
+ if (*cp == c)
+ return (cp);
+ } while (*cp++ != '\0');
+ return (NULL);
+}
+
+/*
+ * External function entry point.
+ */
+int
+getopt(int argc, char *const *argv, const char *optstring)
+{
+ char c;
+ char *cp;
+
+ /*
+ * Has the end of the options been encountered? The following
+ * implements the SUS requirements:
+ *
+ * If, when getopt() is called:
+ * argv[optind] is a null pointer
+ * *argv[optind] is not the character '-'
+ * argv[optind] points to the string "-"
+ * getopt() returns -1 without changing optind. If
+ * argv[optind] points to the string "--"
+ * getopt() returns -1 after incrementing optind.
+ */
+ if (getopt_sp == 1) {
+ if (optind >= argc || argv[optind][0] != '-' ||
+ argv[optind] == NULL || argv[optind][1] == '\0')
+ return (EOF);
+ else if (strcmp(argv[optind], "--") == 0) {
+ optind++;
+ return (EOF);
+ }
+ }
+
+ /*
+ * Getting this far indicates that an option has been encountered.
+ * Note that the syntax of optstring applies special meanings to
+ * the characters ':' and '(', so they are not permissible as
+ * option letters. A special meaning is also applied to the ')'
+ * character, but its meaning can be determined from context.
+ * Note that the specification only requires that the alnum
+ * characters be accepted.
+ */
+ optopt = c = (unsigned char)argv[optind][getopt_sp];
+ optarg = NULL;
+ if ((cp = parse(optstring, c)) == NULL) {
+ /* LINTED: variable format specifier */
+ ERR("illegal option", c);
+ if (argv[optind][++getopt_sp] == '\0') {
+ optind++;
+ getopt_sp = 1;
+ }
+ return ('?');
+ }
+ optopt = c = *cp;
+
+ /*
+ * A valid option has been identified. If it should have an
+ * option-argument, process that now. SUS defines the setting
+ * of optarg as follows:
+ *
+ * 1. If the option was the last character in the string pointed to
+ * by an element of argv, then optarg contains the next element
+ * of argv, and optind is incremented by 2. If the resulting
+ * value of optind is not less than argc, this indicates a
+ * missing option-argument, and getopt() returns an error
+ * indication.
+ *
+ * 2. Otherwise, optarg points to the string following the option
+ * character in that element of argv, and optind is incremented
+ * by 1.
+ *
+ * The second clause allows -abcd (where b requires an option-argument)
+ * to be interpreted as "-a -b cd".
+ */
+ if (*(cp + 1) == ':') {
+ /* The option takes an argument */
+ if (argv[optind][getopt_sp+1] != '\0') {
+ optarg = &argv[optind++][getopt_sp+1];
+ } else if (++optind >= argc) {
+ /* LINTED: variable format specifier */
+ ERR("option requires an argument", c);
+ getopt_sp = 1;
+ optarg = NULL;
+ return (optstring[0] == ':' ? ':' : '?');
+ } else
+ optarg = argv[optind++];
+ getopt_sp = 1;
+ } else {
+ /* The option does NOT take an argument */
+ if (argv[optind][++getopt_sp] == '\0') {
+ getopt_sp = 1;
+ optind++;
+ }
+ optarg = NULL;
+ }
+ return (c);
+} /* getopt() */
+
+#ifdef __APPLE__
+/*
+ * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
+ * into getopt$UNIX2003() by default. Consequently, this function
+ * is called instead of the one defined above. However, optind is
+ * still taken from this file, so in effect, options are not
+ * properly handled. Defining an own getopt$UNIX2003() function
+ * works around this issue.
+ */
+int
+getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
+{
+ return getopt(argc, argv, optstring);
+}
+#endif /* __APPLE__ */
diff --git a/troff/troff.d/devaps/makedev.c b/troff/troff.d/devaps/makedev.c
new file mode 100644
index 000000000000..0854f7969960
--- /dev/null
+++ b/troff/troff.d/devaps/makedev.c
@@ -0,0 +1,650 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "makedev.c 1.7 05/06/08 SMI" */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)makedev.c 1.3 (gritter) 8/9/05
+ */
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+/*
+ * This is a special version of makedev, tailored for the font disk
+ * of the APS-5 in the MH Computing Center. It is not to be used
+ * to set up font description files for other devices.
+ *
+ * makedev:
+ * read text info about a particular device
+ * (e.g., cat, 202, aps5) from file, convert
+ * it into internal (binary) form suitable for
+ * fast reading by troff initialization (ptinit()).
+ *
+ * Usage:
+ *
+ * makedev DESC [ F ... ]
+ * uses DESC to create a description file
+ * using the information therein.
+ * It creates the file DESC.out.
+ *
+ * makedev F ...
+ * makes the font tables for fonts F only,
+ * creates files F.out.
+ *
+ * DESC.out contains:
+ * dev structure with fundamental sizes
+ * list of sizes (nsizes+1) terminated by 0, as short's
+ * indices of char names (nchtab * sizeof (short))
+ * char names as hy\0em\0... (lchname)
+ * nfonts occurrences of
+ * widths (nwidth)
+ * kerning (nwidth) [ascender+descender only so far]
+ * codes (nwidth) to drive actual typesetter
+ * fitab (nchtab+128-32)
+ * each of these is an array of char.
+ *
+ * dev.filesize contains the number of bytes
+ * in the file, excluding the dev part itself.
+ *
+ * F.out contains the font header, width, kern, codes, and fitab.
+ * Width, kern and codes are parallel arrays.
+ * (Which suggests that they ought to be together?)
+ * Later, we might allow for codes which are actually
+ * sequences of formatting info so characters can be drawn.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include "dev.h"
+
+#define BYTEMASK 0377
+
+#define SLANT_BIT 1 /* slant flag is bit 0 */
+#define FONT_BIT 2 /* font flag is bit 1 */
+#define RANGE_BIT 4 /* range flag is bit 2 */
+
+#define SLANT_VAL 3 /* slant angle starts in bit 3 */
+#define RANGE_VAL 5 /* max range starts in bit 5 */
+
+#define skipline(f) while (getc(f) != '\n')
+
+struct dev dev;
+struct Font font;
+
+#define NSIZE 100 /* maximum number of sizes */
+short size[NSIZE];
+#define NCH 256 /* max number of characters with funny names */
+char chname[5*NCH]; /* character names, including \0 for each */
+short chtab[NCH]; /* index of character in chname */
+
+#define NFITAB (NCH + 128-32) /* includes ascii chars, but not non-graphics */
+char fitab[NFITAB]; /* font index table: position of char i on this font. */
+ /* zero if not there */
+
+#define FSIZE 256 /* size of a physical font (e.g., 102 for cat) */
+char width[FSIZE]; /* width table for a physical font */
+char kern[FSIZE]; /* ascender+descender info */
+char code[FSIZE]; /* actual device codes for a physical font */
+char alt_code[FSIZE]; /* code for alternate font */
+int alt_font[FSIZE]; /* alternate font to use */
+
+int dbg = 0; /* debug flag */
+int verbose = 0;
+
+#define NFONT 60 /* max number of default fonts */
+char fname[NFONT][10]; /* temp space to hold default font names */
+
+int fflag = 0; /* on if font table to be written */
+int fdout; /* output file descriptor */
+char *fout = "DESC.out";
+
+int dofont(char *name);
+int getlig(FILE *fin);
+void dump_font(void);
+void finish_line(char *buf, int nw);
+void add_font(char *name);
+
+int
+main(int argc, char *argv[])
+{
+ FILE *fin;
+ char cmd[100], *p;
+ int i, totfont, v;
+
+ if (!strcmp(argv[1], "-v")) {
+ verbose = 1;
+ argv++;
+ argc--;
+ }
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: makedev [-v] [DESC] [fonts]\n");
+ exit(1);
+ }
+
+ if ((fin = fopen("DESC", "r")) == NULL) {
+ fprintf(stderr, "makedev: can't open %s\n", argv[1]);
+ exit(1);
+ }
+ while (fscanf(fin, "%s", cmd) != EOF) {
+ if (cmd[0] == '#') /* comment */
+ skipline(fin);
+ else if (strcmp(cmd, "debug") == 0)
+ dbg++;
+ else if (strcmp(cmd, "res") == 0) {
+ fscanf(fin, "%hd", &dev.res);
+ } else if (strcmp(cmd, "hor") == 0) {
+ fscanf(fin, "%hd", &dev.hor);
+ } else if (strcmp(cmd, "vert") == 0) {
+ fscanf(fin, "%hd", &dev.vert);
+ } else if (strcmp(cmd, "unitwidth") == 0) {
+ fscanf(fin, "%hd", &dev.unitwidth);
+ } else if (strcmp(cmd, "sizescale") == 0) {
+ fscanf(fin, "%hd", &dev.sizescale);
+ } else if (strcmp(cmd, "paperwidth") == 0) {
+ fscanf(fin, "%hd", &dev.paperwidth);
+ } else if (strcmp(cmd, "paperlength") == 0) {
+ fscanf(fin, "%hd", &dev.paperlength);
+ } else if (strcmp(cmd, "biggestfont") == 0) {
+ fscanf(fin, "%hd", &dev.biggestfont);
+ } else if (strcmp(cmd, "spare2") == 0) {
+ fscanf(fin, "%hd", &dev.spare2);
+ } else if (strcmp(cmd, "sizes") == 0) {
+ dev.nsizes = 0;
+ while (fscanf(fin, "%d", &v) != EOF && v != 0)
+ size[dev.nsizes++] = v;
+ size[dev.nsizes] = 0; /* need an extra 0 at the end */
+ } else if (strcmp(cmd, "fonts") == 0) {
+ fscanf(fin, "%hd", &dev.nfonts);
+ for (i = 0; i < dev.nfonts; i++)
+ fscanf(fin, "%s", fname[i]);
+ } else if (strcmp(cmd, "charset") == 0) {
+ p = chname;
+ dev.nchtab = 0;
+ while (fscanf(fin, "%s", p) != EOF) {
+ chtab[dev.nchtab++] = p - chname;
+ while (*p++) /* skip to end of name */
+ ;
+ }
+ dev.lchname = p - chname;
+ chtab[dev.nchtab++] = 0; /* terminate properly */
+ } else
+ fprintf(stderr, "makedev: unknown command %s\n", cmd);
+ }
+ if (argc > 0 && strcmp(argv[1], "DESC") == 0) {
+ fdout = creat(fout, 0666);
+ if (fdout < 0) {
+ fprintf(stderr, "makedev: can't open %s\n", fout);
+ exit(1);
+ }
+ write(fdout, &dev, sizeof (struct dev));
+ /* we need a 0 on the end */
+ write(fdout, size, (dev.nsizes+1) * sizeof (size[0]));
+ write(fdout, chtab, dev.nchtab * sizeof (chtab[0]));
+ write(fdout, chname, dev.lchname);
+ totfont = 0;
+ for (i = 0; i < dev.nfonts; i++) {
+ totfont += dofont(fname[i]);
+ write(fdout, &font, sizeof (struct Font));
+ write(fdout, width, font.nwfont & BYTEMASK);
+ write(fdout, kern, font.nwfont & BYTEMASK);
+ write(fdout, code, font.nwfont & BYTEMASK);
+ write(fdout, fitab, dev.nchtab+128-32);
+ }
+ /* back to beginning to install proper size */
+ lseek(fdout, 0L, 0);
+ dev.filesize = /* excluding dev struct itself */
+ (dev.nsizes+1) * sizeof (size[0])
+ + dev.nchtab * sizeof (chtab[0])
+ + dev.lchname * sizeof (char)
+ + totfont * sizeof (char);
+ write(fdout, &dev, sizeof (struct dev));
+ close(fdout);
+ argc--;
+ argv++;
+ }
+ for (i = 1; i < argc; i++)
+ dofont(argv[i]);
+ exit(0);
+}
+
+
+int
+dofont(char *name)
+ /* string containing name of font */
+{
+
+
+ FILE *fin; /* input file descriptor */
+ int fdout; /* output file descriptor */
+ int i, nw = 0, spacewidth, n = 0, v;
+ char buf[100], ch[10], s1[10], s2[10], s3[10], cmd[30];
+ char s4[10]; /* used to check for extra info */
+ int count; /* value returned from sscanf() */
+ int dflt_range; /* default maximum range for font */
+ int dflt_slant; /* default slant for this font */
+
+ /*
+ * This routine is responsible for making the '.out' file for
+ * the font specified by the parameter name. It also sets up some
+ * of the data structures needed to make the DESC.out file in the
+ * main routine. In addition I have changed this routine so that
+ * we can add some typesetter dependent parameters to the font
+ * files and have this information dumped out to a 'add' file
+ * for this font, which can be read as needed by the aps driver.
+ */
+ if ((fin = fopen(name, "r")) == NULL) {
+ fprintf(stderr, "makedev: can't open font %s\n", name);
+ exit(2);
+ } /* End if */
+
+ sprintf(cmd, "%s.out", name); /* output file is name.out */
+ fdout = creat(cmd, 0666);
+
+ font.specfont = 0; /* by default it isn't special font */
+ font.ligfont = 0; /* and has no ligatures */
+ font.spare1 = 0; /* all the flags are initially off */
+ spacewidth = 0; /* really useful for CW font */
+ dflt_range = 3; /* max range available on our APS-5 */
+ dflt_slant = 0; /* no slant for this font yet */
+
+ for (i = 0; i < NFITAB; i++) /* initialize font index table */
+ fitab[i] = 0;
+
+ for (i = 0; i < FSIZE; i++) { /* initialize font index table */
+ width[i] = kern[i] = code[i] = 0;
+ alt_font[i] = 0;
+ alt_code[i] = 0;
+ } /* End for */
+
+ while (fscanf(fin, "%s", cmd) != EOF) { /* read the font file */
+
+ if (cmd[0] == '#')
+ skipline(fin);
+ else if (strcmp(cmd, "name") == 0)
+ fscanf(fin, "%s", font.namefont);
+ else if (strcmp(cmd, "internalname") == 0)
+ fscanf(fin, "%s", font.intname);
+ else if (strcmp(cmd, "special") == 0)
+ font.specfont = 1;
+ else if (strcmp(cmd, "ligatures") == 0) {
+ font.ligfont = getlig(fin);
+ } else if (strcmp(cmd, "spacewidth") == 0) {
+ fscanf(fin, "%d", &spacewidth);
+ /* width of space on this font */
+ width[0] = spacewidth;
+ } else if (strcmp(cmd, "charset") == 0) {
+ skipline(fin);
+ nw = 0;
+
+ /* widths are origin 1 so fitab==0 can mean */
+ /* "not there" */
+
+ while (fgets(buf, 100, fin) != NULL) {
+
+ count = sscanf(buf, "%s %s %s %s %s", ch, s1,
+ s2, s3, s4);
+
+ if (s1[0] != '"') {
+ /* it's a genuine new character */
+
+ nw++;
+ width[nw] = atoi(s1);
+ kern[nw] = atoi(s2);
+
+ /* temporarily, pick up one byte as */
+ /* code */
+
+ if (s3[0] == '0')
+ sscanf(s3, "%o", &i);
+ else
+ sscanf(s3, "%d", &i);
+ code[nw] = i;
+
+ if (count > 4 && font.spare1)
+ finish_line(buf, nw);
+
+ } /* End if */
+
+ /* otherwise it's a synonym for previous */
+ /* character, so leave previous values intact */
+
+ if (strlen(ch) == 1) /* it's ascii */
+ fitab[ch[0] - 32] = nw;
+ /* fitab origin omits non-graphics */
+ else { /* it has a funny name */
+ for (i = 0; i < dev.nchtab; i++)
+ if (strcmp(&chname[chtab[i]],
+ ch) == 0) {
+ /* starts after the */
+ /* ascii */
+ fitab[i + 128-32] = nw;
+ break;
+ } /* End if */
+
+ if (i >= dev.nchtab)
+ fprintf(stderr,
+ "makedev: font %s: %s not "
+ "in charset\n", name, ch);
+ } /* End else */
+
+ } /* End while */
+ nw++;
+ if (dev.biggestfont >= nw)
+ n = dev.biggestfont;
+ else {
+ if (dev.biggestfont > 0)
+ fprintf(stderr, "font %s too big\n",
+ name);
+ n = nw;
+ }
+ font.nwfont = n;
+ } else if (strcmp(cmd, "alternate_font") == 0)
+ font.spare1 |= FONT_BIT; /* set alternate font bit */
+ else if (strcmp(cmd, "default_slant") == 0) {
+ /* clear two slant val bits */
+ font.spare1 &= ~(3 << SLANT_VAL);
+ /* set font slant bit */
+ font.spare1 |= SLANT_BIT;
+ /* read the default slant value */
+ fscanf(fin, "%d", &dflt_slant);
+ if (dflt_slant > 0) /* encode it as 01 */
+ font.spare1 |= (1 << SLANT_VAL);
+ else if (dflt_slant < 0) /* encode it as 10 */
+ font.spare1 |= (1 << (SLANT_VAL + 1));
+ } else if (strcmp(cmd, "max_range") == 0) {
+ /* set range bit in spare1 */
+ font.spare1 |= RANGE_BIT;
+ /* read default font slant */
+ fscanf(fin, "%d", &dflt_range);
+ if (dflt_range < 1 || dflt_range > 4) {
+ fprintf(stderr,
+ "makedev: illegal default range %d\n",
+ dflt_range);
+ exit(1);
+ } /* End if */
+ font.spare1 |= (dflt_range << RANGE_VAL);
+ } else if (strcmp(cmd, "debug") == 0)
+ dbg++;
+
+ } /* End while */
+
+ if (spacewidth == 0)
+ width[0] = dev.res * dev.unitwidth / 72 / 3;
+ fclose(fin);
+
+ write(fdout, &font, sizeof (struct Font));
+ write(fdout, width, font.nwfont & BYTEMASK);
+ write(fdout, kern, font.nwfont & BYTEMASK);
+ write(fdout, code, font.nwfont & BYTEMASK);
+ write(fdout, fitab, dev.nchtab+128-32);
+ close(fdout);
+
+ if (font.spare1)
+ add_font(name);
+
+ if (dbg)
+ dump_font();
+
+ v = sizeof (struct Font) + 3 * n + dev.nchtab + 128-32;
+ if (verbose)
+ fprintf(stderr, "%3s: %3d chars, width %3d, size %3d\n",
+ font.namefont, nw, width[0], v);
+ return (v);
+
+} /* End of dofont */
+
+
+/* pick up ligature list */
+int
+getlig(FILE *fin)
+{
+
+
+ int lig;
+ char temp[100];
+
+
+ lig = 0;
+ while (fscanf(fin, "%s", temp) != EOF && strcmp(temp, "0") != 0) {
+ if (strcmp(temp, "fi") == 0)
+ lig |= LFI;
+ else if (strcmp(temp, "fl") == 0)
+ lig |= LFL;
+ else if (strcmp(temp, "ff") == 0)
+ lig |= LFF;
+ else if (strcmp(temp, "ffi") == 0)
+ lig |= LFFI;
+ else if (strcmp(temp, "ffl") == 0)
+ lig |= LFFL;
+ else
+ fprintf(stderr, "illegal ligature %s\n", temp);
+ }
+
+ skipline(fin);
+ return (lig);
+
+} /* End of getlg */
+
+
+void
+finish_line(
+ char *buf, /* last input line */
+ int nw) /* data for next char goes here */
+{
+
+
+ char s[3][20]; /* used for special char commands */
+ char v[3][20]; /* and their values */
+ int count; /* number of extra commands */
+ int range; /* largest allowed master range */
+ int angle; /* slant the character by this much */
+ int i; /* loop index */
+
+
+/*
+ *
+ * Called from dofont() to interpret any extra fields in the current input
+ * line. The additional stuff can include one or more of the following
+ *
+ * slant n
+ * max_range n
+ * font n
+ *
+ * separated by white space and in any order. In all the above n is an
+ * integer. Comments will really screw things up so leave them out of the
+ * charset part in the APS-5 font files.
+ *
+ */
+
+
+ count = sscanf(buf, "%*s %*s %*s %*s %s %s %s %s %s %s",
+ s[0], v[0], s[1], v[1], s[2], v[2]);
+
+ if ((count % 2 != 0) || (count == 0)) {
+ fprintf(stderr, "makedev: format error in charset table\n");
+ exit(1);
+ } /* End if */
+
+ alt_code[nw] = code[nw]; /* real code will go in .add file */
+ code[nw] = 128; /* tells daps it's not a real code */
+
+ for (i = 0; i < count/2; i++) {
+
+ if (strcmp(s[i], "font") == 0) {
+ /* get char from another font */
+ /* daps checks this bit */
+ code[nw] |= FONT_BIT;
+ alt_font[nw] = atoi(v[i]); /* APS-5 font number */
+ } else if (strcmp(s[i], "max_range") == 0) {
+ code[nw] &= ~(3 << RANGE_VAL);
+ code[nw] |= RANGE_BIT;
+ range = atoi(v[i]);
+ if (range < 1 || range > 4) {
+ fprintf(stderr, "makedev: illegal range\n");
+ exit(1);
+ } /* End if */
+ code[nw] |= (range << RANGE_VAL);
+ } else if (strcmp(s[i], "slant") == 0) {
+ code[nw] &= ~(3 << SLANT_VAL);
+ code[nw] |= SLANT_BIT;
+ angle = atoi(v[i]);
+ if (angle > 0) /* again daps understands these */
+ code[nw] |= (1 << SLANT_VAL);
+ else if (angle < 0)
+ code[nw] |= (1 << (SLANT_VAL + 1));
+ } else {
+ fprintf(stderr, "makedev: illegal command\n");
+ exit(1);
+ } /* End else */
+
+ } /* End for */
+ if (code[nw] & BYTEMASK == 128) {
+ fprintf(stderr, "makedev: char code %d less than 129\n",
+ code[nw]);
+ exit(1);
+ } /* End if */
+
+} /* End of finish_line */
+
+
+void
+add_font(char *name)
+{
+
+
+ int fdout; /* output file descriptor */
+ int k; /* number of width entries */
+ char cmd[30]; /* used to create output file */
+
+
+
+/*
+ *
+ * If there were any special requests made in the current font file we'll
+ * want to save the real data (for daps) in a binary file that ends with
+ * the suffix ".add". When daps tries to print a character and finds that
+ * it's character code bigger than 129 it knows it will need to get more
+ * real data from the appropriate .add file.
+ *
+ */
+
+
+
+ sprintf(cmd, "%s.add", name); /* file will be 'name'.add */
+ fdout = creat(cmd, 0666);
+
+ k = font.nwfont & BYTEMASK;
+
+ write(fdout, alt_font, k * sizeof (alt_font[0]));
+ write(fdout, alt_code, k);
+
+ close(fdout);
+
+} /* End of add_font */
+
+
+void
+dump_font(void)
+{
+
+
+ int pos; /* position in character tables */
+ int j; /* for loop index */
+ int code_val; /* number in code table */
+
+
+
+/*
+ *
+ * Just a debugging routine that's really not important anymore. It's
+ * called from dofont() after everything's been built for the current
+ * font file. Need to include the string "debug" in the font file that
+ * we want to check.
+ *
+ */
+
+
+ printf("DATA FOR FONT %s:\n\n", font.namefont);
+
+ printf(" font structure data:\n");
+ printf("\t\tfont.nwfont = %d\n", font.nwfont & BYTEMASK);
+ printf("\t\tfont.specfont = %d\n", font.specfont & BYTEMASK);
+ printf("\t\tfont.ligfont = %d\n", font.ligfont & BYTEMASK);
+ printf("\t\tfont.spare1 = 0%o\n", font.spare1 & BYTEMASK);
+ printf("\t\tfont.intname = %s\n\n", font.intname);
+
+ printf(" CHAR WIDTH KERN CODE INDEX\n");
+
+ for (j = 0; j < dev.nchtab + 128 - 32; j++) {
+
+ if ((pos = fitab[j] & BYTEMASK) != 0) {
+ if (j >= 96)
+ printf("%5s", &chname[chtab[j-96]]);
+ else printf("%5c", (j + 32) & BYTEMASK);
+ printf("%10d", width[pos] & BYTEMASK);
+ printf("%10d", kern[pos] & BYTEMASK);
+ code_val = code[pos] & BYTEMASK;
+ printf("%10d", code_val & BYTEMASK);
+ printf("%10d", j);
+
+ if (code_val > 128) {
+ printf("%5d", alt_code[pos] & BYTEMASK);
+ if (code_val & SLANT_BIT)
+ printf(" slant %d",
+ (code_val >> SLANT_VAL) & 03);
+ if (code_val & FONT_BIT)
+ printf(" font %d", alt_font[pos]);
+ if (code_val & RANGE_BIT)
+ printf(" range %d",
+ (code_val >> RANGE_VAL) & 03);
+ } /* End if */
+
+ printf("\n");
+ } /* End if */
+
+ } /* End for */
+
+ printf("\n\n");
+
+} /* End of dump_font */
diff --git a/troff/troff.d/devaps/version b/troff/troff.d/devaps/version
new file mode 100644
index 000000000000..901040d7aa65
--- /dev/null
+++ b/troff/troff.d/devaps/version
@@ -0,0 +1,34 @@
+#ident "@(#)version 1.4 05/06/08 SMI"
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# University Copyright- Copyright (c) 1982, 1986, 1988
+# The Regents of the University of California
+# All Rights Reserved
+#
+# University Acknowledgment- Portions of this document are derived from
+# software developed by the University of California, Berkeley, and its
+# contributors.
+#
+063285
diff --git a/troff/troff.d/devaps/version.c b/troff/troff.d/devaps/version.c
new file mode 100644
index 000000000000..929c5b4ceea4
--- /dev/null
+++ b/troff/troff.d/devaps/version.c
@@ -0,0 +1,19 @@
+#if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4
+#define USED __attribute__ ((used))
+#elif defined __GNUC__
+#define USED __attribute__ ((unused))
+#else
+#define USED
+#endif
+static const char sccsid[] USED = "@(#)/usr/ucb/daps.sl 1.5 (gritter) 7/9/06";
+/* SLIST */
+/*
+aps.h: * Sccsid @(#)aps.h 1.3 (gritter) 8/9/05
+build.c: * Sccsid @(#)build.c 1.4 (gritter) 8/13/05
+daps.c: * Sccsid @(#)daps.c 1.8 (gritter) 7/9/06
+daps.h: * Sccsid @(#)daps.h 1.3 (gritter) 8/9/05
+dev.h: * Sccsid @(#)dev.h 1.3 (gritter) 8/9/05
+draw.c: Sccsid @(#)draw.c 1.1 (gritter) 7/3/06
+getopt.c: * Sccsid @(#)getopt.c 1.8 (gritter) 8/2/05
+makedev.c: * Sccsid @(#)makedev.c 1.3 (gritter) 8/9/05
+*/
diff --git a/troff/troff.d/dhtml/Makefile.mk b/troff/troff.d/dhtml/Makefile.mk
new file mode 100644
index 000000000000..2df615f95fb4
--- /dev/null
+++ b/troff/troff.d/dhtml/Makefile.mk
@@ -0,0 +1,29 @@
+BST= ../../../stuff/bst
+BIN= dhtml
+OBJ= main.o dhtml.o tr_out.o char.o lib.o $(BST)/bst.o
+CPPFLAGS= -DFNTDIR='"$(FNTDIR)"' -I$(BST)
+
+all: $(BIN)
+
+install:
+ $(STRIP) $(BIN)
+ $(INSTALL) $(BIN) $(ROOT)$(BINDIR)/
+ sed 's"$$FNTDIR"$(FNTDIR)"g' $(BIN).1 > \
+ $(ROOT)$(MANDIR)/man1/$(BIN).1
+
+clean:
+ rm -f $(OBJ) $(BIN)
+
+mrproper: clean
+
+$(BIN): $(OBJ)
+ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@
+
+.c.o:
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
+
+char.o: char.h main.h $(BST)/bst.h lib.h tr_out.h
+dhtml.o: dhtml.h tr_out.h char.h main.h
+lib.o: main.h $(BST)/bst.h
+main.o: dhtml.h char.h
+tr_out.o: tr_out.h main.h $(BST)/bst.h lib.h
diff --git a/troff/troff.d/dhtml/char.c b/troff/troff.d/dhtml/char.c
new file mode 100644
index 000000000000..491ded38f3a1
--- /dev/null
+++ b/troff/troff.d/dhtml/char.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2015, Carsten Kunze
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "char.h"
+#include "main.h"
+#include "bst.h"
+#include "lib.h"
+#include "tr_out.h"
+
+int prevchar;
+
+static struct bst namdat = { NULL, bst_scmp };
+static struct bst chrdat = { NULL, bst_icmp };
+static struct bst numdat = { NULL, bst_icmp };
+
+void
+char_open(void) {
+ char *b;
+ ssize_t s;
+ if (!(b = file2ram(FNTDIR "/devhtml/CHAR", &s))) exit(1);
+ while (1) {
+ char *w, *l;
+ size_t n;
+ int t;
+ if (!(s = lineskip(&b, s))) return;
+ if (!(w = get_word(&b, &s, &n, &t))) return;
+ if (!(l = get_line(&b, &s, NULL))) return;
+ if (n == 1)
+ avl_add(&chrdat, I2BST(*w), S2BST(l));
+ else if (n != 2 && !(t & ~1))
+ avl_add(&numdat, I2BST(atoi(w)), S2BST(l));
+ else
+ avl_add(&namdat, S2BST(w), S2BST(l));
+ }
+}
+
+void
+char_c(int c) {
+ if (c == '`' || c == '\'') {
+ if (!prevchar) prevchar = c;
+ else if (c != prevchar) {
+ chrout(prevchar);
+ prevchar = c;
+ } else {
+ switch (c) {
+ case '`' : fputs("&ldquo;", stdout); break;
+ case '\'': fputs("&rdquo;", stdout); break;
+ }
+ prevchar = 0;
+ }
+ } else {
+ clslig();
+ chrout(c);
+ }
+ hdecr();
+}
+
+void
+char_N(int i) {
+ struct bst_node *n;
+ clslig();
+ if (!bst_srch(&numdat, I2BST(i), &n))
+ fputs(n->data.p, stdout);
+ else
+ printf("&#%d;", i);
+ hdecr();
+}
+
+void
+char_C(char *s) {
+ struct bst_node *n;
+ clslig();
+ if (!bst_srch(&namdat, S2BST(s), &n))
+ fputs(n->data.p, stdout);
+ else
+ fprintf(stderr, "%s: Unknown character name \"%s\"\n",
+ progname, s);
+ hdecr();
+}
+
+void
+chrout(int c) {
+ struct bst_node *n;
+ if (!bst_srch(&chrdat, I2BST(c), &n))
+ fputs(n->data.p, stdout);
+ else
+ putchar(c);
+}
diff --git a/troff/troff.d/dhtml/char.h b/troff/troff.d/dhtml/char.h
new file mode 100644
index 000000000000..cd3aefd6cf3b
--- /dev/null
+++ b/troff/troff.d/dhtml/char.h
@@ -0,0 +1,15 @@
+#define clslig() \
+ do { \
+ if (prevchar) { \
+ chrout(prevchar); \
+ prevchar = 0; \
+ } \
+ } while (0)
+
+void char_open(void);
+void char_c(int);
+void char_C(char *);
+void char_N(int);
+void chrout(int);
+
+extern int prevchar;
diff --git a/troff/troff.d/dhtml/dhtml.1 b/troff/troff.d/dhtml/dhtml.1
new file mode 100644
index 000000000000..beb09286f1af
--- /dev/null
+++ b/troff/troff.d/dhtml/dhtml.1
@@ -0,0 +1,107 @@
+.\" Copyright (c) 2015, Carsten Kunze
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright notice,
+.\" this list of conditions and the following disclaimer.
+.\"
+.\" 2. Redistributions in binary form must reproduce the above copyright notice,
+.\" this list of conditions and the following disclaimer in the documentation
+.\" and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.Dd September 18, 2015
+.Dt DHTML 1
+.Sh NAME
+.Nm dhtml
+.Nd HTML postprocessor for troff
+.Sh SYNOPSIS
+.Nm
+.Op Fl t Ar title
+.Li < Ar ditroff_output Li > Ar html_output
+.Sh DESCRIPTION
+.Nm
+is a HTML postprocessor for
+.Xr troff 1 .
+It reads the ditroff output from
+.Dv STDIN
+and writes HTML5 output to
+.Dv STDOUT .
+.Nm troff
+must in this case be called with option
+.Fl Thtml .
+Missing charaters can be added by changing the files
+.Pa charset
+and
+.Pa CHAR
+(see section
+.Sx FILES ) .
+For adding fonts the tool needs to be recompiled (currently the
+legacy fonts
+.Li R I B BI C CW CR CI CB H HI HB S
+are available).
+.Pp
+Options:
+.Bl -tag -width ".Fl t Ar title"
+.It Fl t Ar title
+Set text for the HTML
+.Li <title>
+tag.
+.El
+.Sh FILES
+.Bl -tag
+.It Ar source_dir Ns Pa /troff/troff.d/font/devhtml/charset
+.Sy charset
+which is appended to each font description file at installation
+of the tool (run
+.Pp
+.Dl # make install
+.Pp
+after changes of this file).
+.It Pa $FNTDIR/devhtml/CHAR
+Character to HTML name mapping which is read at each run of
+.Nm .
+.El
+.Sh EXAMPLES
+.Bd -unfilled -offset indent
+.Li tbl Ar manpage Li | troff -Thtml -mandoc \(rs
+.Li " |" dhtml Li -t Ar html_title Li > Ar html_file
+.Ed
+.Pp
+Convert
+.Ar manpage
+into HTML format with title
+.Ar html_title
+and save it as
+.Ar html_file .
+.Sh SEE ALSO
+.Xr troff 1 ,
+.Xr dpost 1
+.Sh BUGS
+For the current version no changes to the ditroff interface are done.
+All information for formatting the HTML page is taken from legacy ditroff
+commands.
+As a consequence the alignment cannot be as accurate as in the
+.Xr dpost 1
+output since the character widths of HTML fonts must be supposed to be
+unknown.
+.Pp
+At the moment no HTML tables are generated.
+.Xr tbl 1
+(without options) can be used for preprocessing but mayor alingment issues
+may result.
+There is no support for equations, graphics, images, and links in this
+versions.
+These features are subject to be implemented later.
diff --git a/troff/troff.d/dhtml/dhtml.h b/troff/troff.d/dhtml/dhtml.h
new file mode 100644
index 000000000000..1c4d1be54f51
--- /dev/null
+++ b/troff/troff.d/dhtml/dhtml.h
@@ -0,0 +1 @@
+void run_lex(void);
diff --git a/troff/troff.d/dhtml/dhtml.l b/troff/troff.d/dhtml/dhtml.l
new file mode 100644
index 000000000000..c99db26a88a1
--- /dev/null
+++ b/troff/troff.d/dhtml/dhtml.l
@@ -0,0 +1,87 @@
+%{
+/*
+ * Copyright (c) 2015, Carsten Kunze
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <string.h>
+#include "dhtml.h"
+#include "tr_out.h"
+#include "char.h"
+#include "main.h"
+static int i0;
+%}
+%x X FONT_NUM FONT_NAM T X_X LINK ULINK ANCHOR
+WS [ ]
+NWS [^ \n]
+%%
+<X>f{NWS}*{WS}+ { BEGIN FONT_NUM; }
+<X>T{NWS}*{WS}+ { BEGIN T; }
+<X>X{NWS}*{WS}+ { BEGIN X_X; }
+<X>[^fTX].* { BEGIN 0; }
+<FONT_NUM>[0-9]+{WS}+ { i0 = atoi(yytext);
+ BEGIN FONT_NAM; }
+<FONT_NAM>{NWS}+ { out_x_f(i0, yytext);
+ BEGIN 0; }
+<T>{NWS}+ { out_x_T(yytext);
+ BEGIN 0; }
+<X_X>Link{WS}+ { BEGIN LINK; }
+<X_X>ULink{WS}+ { BEGIN ULINK; }
+<X_X>U?Link{WS}*\n { out_end_link();
+ BEGIN 0; }
+<X_X>Anchor{WS}+ { BEGIN ANCHOR; }
+<X_X>LC_TYPE.* { BEGIN 0; }
+<X_X>[^AL].* { BEGIN 0; }
+<LINK>.+ { out_begin_link(yytext);
+ BEGIN 0; }
+<ULINK>.+ { out_begin_ulink(yytext);
+ BEGIN 0; }
+<ANCHOR>.+ { out_anchor(yytext);
+ BEGIN 0; }
+c. { char_c(yytext[1]); }
+[0-9][0-9]. { char_c(yytext[2]); }
+C{NWS}+ { char_C(yytext+1); }
+w { out_w(); }
+H-?[0-9]+ { ; }
+h-?[0-9]+ { out_h(atoi(yytext+1)); }
+V-?[0-9]+ { out_V(atoi(yytext+1)); }
+v-?[0-9]+ { fprintf(stderr, "Ignore v %s\n", yytext+1); }
+f[0-9]+ { out_f(atoi(yytext+1)); }
+N[0-9]+ { char_N(atoi(yytext+1)); }
+n[0-9]+{WS}+[0-9]+ { out_n(atoi(yytext+1)); }
+s[0-9]+ { out_s(atoi(yytext+1)); }
+p[0-9]+ { ; }
+x{WS}+ { BEGIN X; }
+D.+ { ; }
+\n { ; }
+. { fprintf(stderr, "Ignore '%c'\n", *yytext); }
+%%
+int
+yywrap(void) {
+ return 1;
+}
+void
+run_lex(void) {
+ yylex();
+}
diff --git a/troff/troff.d/dhtml/lib.c b/troff/troff.d/dhtml/lib.c
new file mode 100644
index 000000000000..251223627e05
--- /dev/null
+++ b/troff/troff.d/dhtml/lib.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2015, Carsten Kunze
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include "main.h"
+#include "bst.h"
+
+void * /* pointer to \0 terminated file contents */
+file2ram(char *p, /* path to file */
+ ssize_t *l) { /* pointer to buffer size variable */
+ int f;
+ struct stat s;
+ char *b = NULL;
+ if ((f = open(p, O_RDONLY)) == -1) {
+ fprintf(stderr, "%s: open(%s) failed: ", progname, p);
+ perror(NULL);
+ goto r;
+ }
+ if (fstat(f, &s) == -1) {
+ fprintf(stderr, "%s: fstat(%s) failed: ", progname, p);
+ perror(NULL);
+ goto c;
+ }
+ if (!(b = malloc(s.st_size + 1))) goto c;
+ if ((*l = read(f, b, s.st_size)) == -1) {
+ free(b);
+ fprintf(stderr, "%s: read(%s) failed: ", progname, p);
+ perror(NULL);
+ goto c;
+ }
+ b[*l] = 0;
+c:
+ close(f);
+r:
+ return b;
+}
+
+ssize_t
+lineskip(char **b, ssize_t n) {
+ char *p = *b;
+ int i = 0;
+ int c;
+ while (1) {
+ for (; n && (!(c = *p) || c == ' ' || c == '\t' || c == '\n');
+ n--, p++) {
+ if (c == '\n') i = 0;
+ else i++;
+ }
+ if (!n || !i || c != '#') goto r;
+ for (; n && (c = *p) && c != '\n'; n--, p++);
+ }
+r:
+ *b = p;
+ return n;
+}
+
+char * /* pointer to word */
+get_word(char **b, /* begin of buffer, then end of buffer */
+ ssize_t *l, /* buffer length */
+ size_t *s, /* word length (if not NULL) */
+ int *t) { /* type (if not NULL) */
+ char *w = NULL;
+ char *p = *b;
+ ssize_t n = *l;
+ int c;
+ size_t i = 0;
+ int f = 0;
+ for (; n && (!(c = *p) || c == ' ' || c == '\t' || c == '\n');
+ n--, p++);
+ if (!n) goto r;
+ w = p;
+ for (; n && (c = *p) && c != ' ' && c != '\t' && c != '\n';
+ i++, n--, p++) {
+ if (c >= '0' && c <= '9') f |= 1;
+ else f |= 2;
+ }
+ if (!n) goto r;
+ *p = 0;
+r:
+ *b = p;
+ *l = n;
+ if (s) *s = i;
+ if (t) *t = f;
+ return w;
+}
+
+char * /* pointer to line */
+get_line(char **b, /* begin of buffer, then end of buffer */
+ ssize_t *l, /* buffer length */
+ size_t *s) { /* line length (if not NULL) */
+ char *w = NULL;
+ char *p = *b;
+ ssize_t n = *l;
+ int c;
+ size_t i = 0;
+ for (; n && (!(c = *p) || c == ' ' || c == '\t');
+ n--, p++);
+ if (!n) goto r;
+ w = p;
+ for (; n && (c = *p) && c != '\n'; i++, n--, p++);
+ if (!n) goto r;
+ *p = 0;
+r:
+ *b = p;
+ *l = n;
+ if (s) *s = i;
+ return w;
+}
+
+int
+bst_scmp(union bst_val a, union bst_val b) {
+ return strcmp(a.p, b.p);
+}
+int
+bst_icmp(union bst_val a, union bst_val b) {
+ return a.i < b.i ? -1 :
+ a.i > b.i ? 1 :
+ 0 ;
+}
diff --git a/troff/troff.d/dhtml/lib.h b/troff/troff.d/dhtml/lib.h
new file mode 100644
index 000000000000..7f8d5b591ffa
--- /dev/null
+++ b/troff/troff.d/dhtml/lib.h
@@ -0,0 +1,9 @@
+#define I2BST(i) ((union bst_val)(int)i)
+#define S2BST(s) ((union bst_val)(void *)s)
+
+void *file2ram(char *, ssize_t *);
+ssize_t lineskip(char **, ssize_t);
+char *get_word(char **, ssize_t *, size_t *, int *);
+char *get_line(char **, ssize_t *, size_t *);
+int bst_scmp(union bst_val, union bst_val);
+int bst_icmp(union bst_val, union bst_val);
diff --git a/troff/troff.d/dhtml/main.c b/troff/troff.d/dhtml/main.c
new file mode 100644
index 000000000000..ece790332794
--- /dev/null
+++ b/troff/troff.d/dhtml/main.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, Carsten Kunze
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "dhtml.h"
+#include "char.h"
+
+char *progname;
+
+static void begin_html(void);
+static void end_html(void);
+
+static char *title;
+
+int
+main(int argc, char **argv) {
+ int opt;
+ progname = argv[0];
+ while ((opt = getopt(argc, argv, "t:")) != -1) {
+ switch (opt) {
+ case 't':
+ title = optarg;
+ break;
+ default:
+ fprintf(stderr, "Usage: %s [-t title] < "
+ "ditroff_output > html_output\n", progname);
+ exit(EXIT_FAILURE);
+ }
+ }
+ begin_html();
+ char_open();
+ run_lex();
+ end_html();
+ return 0;
+}
+
+static void
+begin_html(void) {
+ puts("<!DOCTYPE html>");
+ puts("<html lang=\"en\">");
+ puts(" <head>");
+ puts(" <meta charset=\"utf-8\">");
+ printf(" <title>%s</title>", title ? title : "");
+ puts(" </head>");
+ puts(" <body>");
+}
+
+static void
+end_html(void) {
+ puts("");
+ puts(" </body>");
+ puts("</html>");
+}
diff --git a/troff/troff.d/dhtml/main.h b/troff/troff.d/dhtml/main.h
new file mode 100644
index 000000000000..0aca5f172b38
--- /dev/null
+++ b/troff/troff.d/dhtml/main.h
@@ -0,0 +1 @@
+extern char *progname;
diff --git a/troff/troff.d/dhtml/roff.c b/troff/troff.d/dhtml/roff.c
new file mode 100644
index 000000000000..760893d24a05
--- /dev/null
+++ b/troff/troff.d/dhtml/roff.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include "roff.h"
+
+static struct req_in_data {
+ int not_1st;
+ int last_i;
+} req_in_data;
+
+void
+req_in(int i) {
+#if 0
+ if (req_in_data.not_1st) {
+ puts("\n</div>");
+ req_in_data.not_1st = 0;
+ }
+ if (i) {
+ printf("\n<div style=\"padding-left: %dpx;\">\n", i);
+ req_in_data.not_1st = 1;
+ }
+#endif
+ puts("<br>");
+}
+
+void
+req_sp(int i) {
+ printf("\n<div style=\"height: %dpx;\"></div>\n", (i*12)/40);
+}
diff --git a/troff/troff.d/dhtml/roff.h b/troff/troff.d/dhtml/roff.h
new file mode 100644
index 000000000000..93150486a60b
--- /dev/null
+++ b/troff/troff.d/dhtml/roff.h
@@ -0,0 +1,2 @@
+void req_in(int);
+void req_sp(int);
diff --git a/troff/troff.d/dhtml/tr_out.c b/troff/troff.d/dhtml/tr_out.c
new file mode 100644
index 000000000000..7fd52c901dd6
--- /dev/null
+++ b/troff/troff.d/dhtml/tr_out.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2015, Carsten Kunze
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "tr_out.h"
+#include "main.h"
+#include "bst.h"
+#include "lib.h"
+#include "char.h"
+
+int fontsize;
+int hdec;
+
+static void closesize(void);
+
+static int lineheight;
+static int totalh;
+static char *size_end;
+static struct bst fonts = { NULL, bst_icmp };
+
+void
+out_x_T(char *dev) {
+ if (!strcmp(dev, "html")) return;
+ fprintf(stderr, "%s: Invalid troff output device \"%s\"."
+ "Please use troff with option \"-Thtml\".\n", progname, dev);
+}
+
+void
+out_f(int num) {
+ static char *prevfont = "R";
+ static char *closefont;
+ struct bst_node *n;
+ char *nam;
+ clslig();
+ if (!bst_srch(&fonts, I2BST(num), &n)) {
+ nam = n->data.p;
+ } else {
+ nam = "R";
+ if (num != 1)
+ fprintf(stderr, "%s: Unknown font %d\n", progname,
+ num);
+ }
+ if (!strcmp(nam, prevfont)) return;
+ closesize();
+ if (closefont) {
+ fputs(closefont, stdout);
+ closefont = NULL;
+ }
+ prevfont = nam;
+ if (!strcmp(nam, "R") ||
+ !strcmp(nam, "S")) return;
+ else
+ if (!strcmp(nam, "I")) {
+ fputs("<span style=\"font-style: italic\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "B")) {
+ fputs("<span style=\"font-weight: bold\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "BI")) {
+ fputs("<span style=\"font-weight: bold;"
+ " font-style: italic\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "CW") ||
+ !strcmp(nam, "CR") ||
+ !strcmp(nam, "C")) {
+ fputs("<span style=\"font-family: monospace\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "CI")) {
+ fputs("<span style=\"font-family: monospace;"
+ " font-style: italic\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "CB")) {
+ fputs("<span style=\"font-family: monospace;"
+ " font-weight: bold\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "H")) {
+ fputs("<span style=\"font-family: sans-serif\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "HI")) {
+ fputs("<span style=\"font-family: sans-serif;"
+ " font-style: italic\">", stdout);
+ closefont = "</span>";
+ } else
+ if (!strcmp(nam, "HB")) {
+ fputs("<span style=\"font-family: sans-serif;"
+ " font-weight: bold\">", stdout);
+ closefont = "</span>";
+ } else
+ fprintf(stderr, "%s: Unknown font name \"%s\"\n",
+ progname, nam);
+ out_s(fontsize);
+}
+
+void
+out_s(int i) {
+ fontsize = i;
+ clslig();
+ closesize();
+ if (fontsize == 10) return;
+ printf("<span style=\"font-size: %gem\">", fontsize / 10.0);
+ size_end = "</span>";
+}
+
+static void
+closesize(void) {
+ if (size_end) {
+ fputs(size_end, stdout);
+ size_end = NULL;
+ }
+}
+
+void
+out_n(int i) {
+ clslig();
+ lineheight = i;
+}
+
+void
+out_V(int i) {
+ static int prevv;
+ int d;
+ clslig();
+ if (i < 0) return;
+ if (i < prevv) {
+ prevv = i;
+ return;
+ }
+ if (!lineheight) return;
+ prevv += lineheight;
+ if ((d = i - prevv) > 0) {
+ printf("<p style=\"heigh: %dpx\"></p>\n", d);
+ prevv = i;
+ } else {
+ puts("<br>");
+ }
+ lineheight = 0;
+ totalh = 0;
+ hdec = 0;
+}
+
+void
+out_h(int i) {
+ if (lineheight) i -= totalh;
+ else totalh += i;
+ i -= hdec;
+ hdec = 0;
+ if (i <= 0) return;
+ printf("<span style=\"display: inline-block; width: %gpt\"></span>",
+ i / 20.0);
+}
+
+void
+out_w(void) {
+ clslig();
+ putchar(' ');
+ hdec += 10 * fontsize;
+}
+
+void
+out_x_f(int num, char *nam) {
+ struct bst_node *n;
+ if (bst_srch(&fonts, I2BST(num), &n)) {
+ avl_add(&fonts, I2BST(num), S2BST(strdup(nam)));
+ } else {
+ free(n->data.p);
+ n->data.p = strdup(nam);
+ }
+}
+
+void
+out_begin_link(char *l) {
+ printf("<a href=\"#%s\">", l);
+}
+
+void
+out_begin_ulink(char *l) {
+ printf("<a href=\"%s\">", l);
+}
+
+void
+out_end_link(void) {
+ fputs("</a>", stdout);
+}
+
+void
+out_anchor(char *a) {
+ printf("<span id=\"%s\"></span>", a);
+}
diff --git a/troff/troff.d/dhtml/tr_out.h b/troff/troff.d/dhtml/tr_out.h
new file mode 100644
index 000000000000..e040bd84d1bc
--- /dev/null
+++ b/troff/troff.d/dhtml/tr_out.h
@@ -0,0 +1,17 @@
+#define hdecr() hdec += 10 * fontsize
+
+void out_anchor(char *);
+void out_begin_link(char *);
+void out_begin_ulink(char *);
+void out_end_link(void);
+void out_f(int);
+void out_h(int);
+void out_n(int);
+void out_s(int);
+void out_V(int);
+void out_w(void);
+void out_x_f(int, char *);
+void out_x_T(char *);
+
+extern int fontsize;
+extern int hdec;
diff --git a/troff/troff.d/dpost.d/Makefile.mk b/troff/troff.d/dpost.d/Makefile.mk
new file mode 100644
index 000000000000..36847f46d999
--- /dev/null
+++ b/troff/troff.d/dpost.d/Makefile.mk
@@ -0,0 +1,42 @@
+BST = ../../../stuff/bst
+
+OBJ = dpost.o draw.o color.o pictures.o ps_include.o afm.o \
+ makedev.o glob.o misc.o request.o version.o getopt.o \
+ asciitype.o otf.o ../fontmap.o $(BST)/bst.o
+
+FLAGS = -I. -I.. -DFNTDIR='"$(FNTDIR)"' -DPSTDIR='"$(PSTDIR)"' $(EUC) \
+ $(DEFINES) -I../../../include -I.. -I$(BST)
+
+.c.o:
+ $(CC) $(CFLAGS) $(WARN) $(CPPFLAGS) $(FLAGS) -c $<
+
+all: dpost
+
+dpost: $(OBJ)
+ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(LIBS) -o dpost
+
+install:
+ $(INSTALL) -c dpost $(ROOT)$(BINDIR)/dpost
+ $(STRIP) $(ROOT)$(BINDIR)/dpost
+ mkdir -p $(ROOT)$(MANDIR)/man1
+ $(INSTALL) -c -m 644 dpost.1 $(ROOT)$(MANDIR)/man1/dpost.1
+
+clean:
+ rm -f $(OBJ) dpost core log *~
+
+mrproper: clean
+
+color.o: color.c gen.h ext.h
+dpost.o: dpost.c comments.h gen.h path.h ext.h ../dev.h dpost.h ../afm.h \
+ asciitype.h
+draw.o: draw.c gen.h ext.h
+glob.o: glob.c gen.h
+misc.o: misc.c gen.h ext.h path.h asciitype.h
+pictures.o: pictures.c comments.h gen.h path.h
+ps_include.o: ps_include.c ext.h gen.h asciitype.h path.h
+request.o: request.c gen.h request.h path.h
+afm.o: afm.c ../dev.h ../afm.h ../afm.c
+otf.o: otf.c ../dev.h ../afm.h ../otf.c
+makedev.o: makedev.c ../dev.h ../makedev.c
+asciitype.o: asciitype.h
+version.o: version.c ../../version.c
diff --git a/troff/troff.d/dpost.d/README b/troff/troff.d/dpost.d/README
new file mode 100644
index 000000000000..a2ad48ed2f31
--- /dev/null
+++ b/troff/troff.d/dpost.d/README
@@ -0,0 +1,53 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+Source code for a program that translates device independent troff output into
+PostScript.
+
+Several new text encoding schemes, based on widthshow, have been added. Each can
+be accessed using the -e option and often reduce print time by 20% or more. Level
+0 is the slowest but most stable choice. Level 2 encoding (which right now is the
+default) is fast and does a good job placing text and justifying the right margin.
+You can change the default encoding scheme by adjusting the definition of ENCODING
+in ../Makefile. Levels 0, 1, and 2 are the only reasonable defaults, but at present
+only level 0 is guaranteed. The new encoding schemes are not thoroughly tested,
+but passed the tests I ran.
+
+Other interesting features include color support, the ability to treat complex
+paths built from the standard drawing commands as single entities (eg. for filling
+a polygon with a color), and reverse video printing as a special case of color.
+Also added, although using it is far from trivial, is the ability to set text
+along an arbitrary baseline (see ../postscript/baseline.ps). All are accessed via
+special device control escapes (from routine devcntrl() in dpost.c).
+
+ASCII font and description files for many standard PostScript fonts can be found
+in ../font/devpost. They should be installed in /usr/lib/font/devpost, and are
+read when you add the -Tpost option to troff. A typical command line would be,
+
+ pic file | tbl | eqn | troff -mm -Tpost | dpost >file.ps
+
+while,
+
+ pic -T720 file | tbl | eqn -r720 | troff -mm -Tpost | dpost >file.ps
+
+should work if you're using old versions of eqn and pic.
+
diff --git a/troff/troff.d/dpost.d/afm.c b/troff/troff.d/dpost.d/afm.c
new file mode 100644
index 000000000000..260691c4d7d8
--- /dev/null
+++ b/troff/troff.d/dpost.d/afm.c
@@ -0,0 +1,32 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)afm.c 1.3 (gritter) 5/1/06
+ */
+
+#define DPOST
+#include "../afm.c"
+
+int NCHARS;
diff --git a/troff/troff.d/dpost.d/asciitype.c b/troff/troff.d/dpost.d/asciitype.c
new file mode 100644
index 000000000000..f7f3221730d4
--- /dev/null
+++ b/troff/troff.d/dpost.d/asciitype.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2003 Gunnar Ritter
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute
+ * it freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+/* Sccsid @(#)asciitype.c 1.4 (gritter) 4/17/03 */
+
+#include "asciitype.h"
+
+const unsigned char class_char[] = {
+/* 000 nul 001 soh 002 stx 003 etx 004 eot 005 enq 006 ack 007 bel */
+ C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,
+/* 010 bs 011 ht 012 nl 013 vt 014 np 015 cr 016 so 017 si */
+ C_CNTRL,C_BLANK,C_WHITE,C_SPACE,C_SPACE,C_SPACE,C_CNTRL,C_CNTRL,
+/* 020 dle 021 dc1 022 dc2 023 dc3 024 dc4 025 nak 026 syn 027 etb */
+ C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,
+/* 030 can 031 em 032 sub 033 esc 034 fs 035 gs 036 rs 037 us */
+ C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,C_CNTRL,
+/* 040 sp 041 ! 042 " 043 # 044 $ 045 % 046 & 047 ' */
+ C_BLANK,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,
+/* 050 ( 051 ) 052 * 053 + 054 , 055 - 056 . 057 / */
+ C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,
+/* 060 0 061 1 062 2 063 3 064 4 065 5 066 6 067 7 */
+ C_OCTAL,C_OCTAL,C_OCTAL,C_OCTAL,C_OCTAL,C_OCTAL,C_OCTAL,C_OCTAL,
+/* 070 8 071 9 072 : 073 ; 074 < 075 = 076 > 077 ? */
+ C_DIGIT,C_DIGIT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,
+/* 100 @ 101 A 102 B 103 C 104 D 105 E 106 F 107 G */
+ C_PUNCT,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,
+/* 110 H 111 I 112 J 113 K 114 L 115 M 116 N 117 O */
+ C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,
+/* 120 P 121 Q 122 R 123 S 124 T 125 U 126 V 127 W */
+ C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,C_UPPER,
+/* 130 X 131 Y 132 Z 133 [ 134 \ 135 ] 136 ^ 137 _ */
+ C_UPPER,C_UPPER,C_UPPER,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,
+/* 140 ` 141 a 142 b 143 c 144 d 145 e 146 f 147 g */
+ C_PUNCT,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,
+/* 150 h 151 i 152 j 153 k 154 l 155 m 156 n 157 o */
+ C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,
+/* 160 p 161 q 162 r 163 s 164 t 165 u 166 v 167 w */
+ C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,C_LOWER,
+/* 170 x 171 y 172 z 173 { 174 | 175 } 176 ~ 177 del */
+ C_LOWER,C_LOWER,C_LOWER,C_PUNCT,C_PUNCT,C_PUNCT,C_PUNCT,C_CNTRL
+};
diff --git a/troff/troff.d/dpost.d/asciitype.h b/troff/troff.d/dpost.d/asciitype.h
new file mode 100644
index 000000000000..5e0eef7f5c1e
--- /dev/null
+++ b/troff/troff.d/dpost.d/asciitype.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2003 Gunnar Ritter
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute
+ * it freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+/* Sccsid @(#)asciitype.h 1.6 (gritter) 9/9/05 */
+
+/*
+ * Locale-independent character classes.
+ */
+enum {
+ C_CNTRL = 0000,
+ C_BLANK = 0001,
+ C_WHITE = 0002,
+ C_SPACE = 0004,
+ C_PUNCT = 0010,
+ C_OCTAL = 0020,
+ C_DIGIT = 0040,
+ C_UPPER = 0100,
+ C_LOWER = 0200
+};
+
+extern const unsigned char class_char[];
+
+#define asciichar(c) ((unsigned)(c) <= 0177)
+#define alnumchar(c) (asciichar(c)&&(class_char[c]&\
+ (C_DIGIT|C_OCTAL|C_UPPER|C_LOWER)))
+#define alphachar(c) (asciichar(c)&&(class_char[c]&(C_UPPER|C_LOWER)))
+#define blankchar(c) (asciichar(c)&&(class_char[c]&(C_BLANK)))
+#define cntrlchar(c) (asciichar(c)&&(class_char[c]==C_CNTRL)
+#define digitchar(c) (asciichar(c)&&(class_char[c]&(C_DIGIT|C_OCTAL)))
+#define lowerchar(c) (asciichar(c)&&(class_char[c]&(C_LOWER)))
+#define punctchar(c) (asciichar(c)&&(class_char[c]&(C_PUNCT)))
+#define spacechar(c) (asciichar(c)&&(class_char[c]&(C_BLANK|C_SPACE|C_WHITE)))
+#define upperchar(c) (asciichar(c)&&(class_char[c]&(C_UPPER)))
+#define whitechar(c) (asciichar(c)&&(class_char[c]&(C_BLANK|C_WHITE)))
+#define octalchar(c) (asciichar(c)&&(class_char[c]&(C_OCTAL)))
+#define graphchar(c) (asciichar(c)&&(class_char[c]&\
+ (C_UPPER|C_LOWER|C_DIGIT|C_OCTAL|C_PUNCT)))
+#define printchar(c) ((c)==' ' || (asciichar(c)&&(class_char[c]&\
+ (C_UPPER|C_LOWER|C_DIGIT|C_OCTAL|C_PUNCT))))
+
+#define upperconv(c) (lowerchar(c) ? (c)-'a'+'A' : (c))
+#define lowerconv(c) (upperchar(c) ? (c)-'A'+'a' : (c))
diff --git a/troff/troff.d/dpost.d/color.c b/troff/troff.d/dpost.d/color.c
new file mode 100644
index 000000000000..4568aec09177
--- /dev/null
+++ b/troff/troff.d/dpost.d/color.c
@@ -0,0 +1,275 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "color.c 1.5 05/06/08 SMI" SVr4.0 1.1 */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)color.c 1.5 (gritter) 11/29/05
+ */
+
+/*
+ *
+ * Routines that handle color requests passed through as device control commands
+ * in the form "x X SetColor:red". The following PostScript procedures are needed:
+ *
+ * _setcolor
+ *
+ * mark /color _setcolor mark
+ * mark /color1 /color2 _setcolor mark
+ *
+ * Called whenever we want to change PostScript's current color graphics
+ * state parameter. One or two color arguments can be given. In each case
+ * the colors are looked up in the PostScript colordict dictionary that's
+ * defined in *colorfile. Two named colors implies reverse video printing
+ * with the background given in /color2 and the text printed in /color1.
+ * Unknown colors are mapped into defaults - black for a single color and
+ * white on black for reverse video.
+ *
+ * drawrvbox
+ *
+ * leftx rightx drawrvbox -
+ *
+ * Fills a box that extends from leftx to rightx with the background color
+ * that was requested when _setcolor set things up for reverse video mode.
+ * The vertical extent of the box is determined using FontBBox just before
+ * the first string is printed, and the height remains in effect until
+ * there's an explicit color change. In otherwords font or size changes
+ * won't always produce correct result in reverse video mode.
+ *
+ * setdecoding
+ *
+ * num setdecoding -
+ *
+ * Selects the text decoding procedure (ie. what's assigned to PostScript
+ * procedure t) from the decodingdefs array defined in the prologue. num
+ * should be the value assigned to variable encoding (in dpost) and will
+ * remain constant throughout a job, unless special features, like reverse
+ * video printing, are requested. The text encoding scheme can be set on
+ * the command line using the -e option. Print time and the size of the
+ * output file will usually decrease as the value assigned to encoding
+ * increases.
+ *
+ *
+ * The recognized collection of "x X SetColor:" commands are:
+ *
+ * x X SetColor: selects black
+ * x X SetColor:color selects color
+ * x X SetColor:color1 on color2 reverse video
+ * x X SetColor:color1 color2 reverse video again
+ * x X SetColor:num1 num2 num3 rgb explicit rgb color request
+ * x X SetColor:num1 num2 num3 hsb explicit hsb color request
+ * x X SetColor:num1 num2 num3 num4 cmyk explicit cmyk color request
+ * x X SetColor:arbitrary PostScript commands
+ *
+ * In the last examples num1, num2, num3, and num4 should be numbers between 0 and
+ * 1 inclusive and are passed on as aguments to the approrpriate PostScript color
+ * command (eg. setrgbcolor). Unknown color names (ie. the ones that _setcolor
+ * doesn't find in colordict) are mapped into defaults. For one color the default
+ * is black, while for reverse video it's white text on a black background.
+ *
+ * dpost makes sure the current color is maintained across page boundaries, which
+ * may not be what you want if you're using a macro package like mm that puts out
+ * page footers and headers. Adding a color request to troff and keeping track of
+ * the color in each environment may be the best solution.
+ *
+ * To get reverse video printing follow the "x X SetColor:" command with two or
+ * three arguments. "x X SetColor:white on black" or "x X SetColor:white black"
+ * both produce white text on a black background. Any two colors named in colordict
+ * (in file *colorfile) can be chosen so "x X SetColor:yellow on blue" also works.
+ * Each reverse video mode request selects the vertical extent of the background
+ * box based on the font and size in use just before the first string is printed.
+ * Font and/or size changes aren't guaranteed to work properly in reverse video
+ * printing.
+ *
+ */
+
+
+#include <stdio.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "gen.h" /* general purpose definitions */
+#include "ext.h" /* external variable definitions */
+#include "global.h" /* global heirloom doctools definitions */
+
+#define DEFAULTCOLOR "black"
+
+static char color[500] = DEFAULTCOLOR; /* current color */
+static int gotcolor = FALSE; /* TRUE after *colorfile is downloaded */
+static int wantcolor = FALSE; /* TRUE if we really ask for a color */
+
+
+/*
+ *
+ * All these should be defined in dpost.c.
+ *
+ */
+
+
+extern int lastend;
+extern int encoding;
+extern int maxencoding;
+extern int realencoding;
+
+extern char *colorfile;
+extern FILE *tf;
+
+
+/*****************************************************************************/
+
+
+void
+getcolor(void)
+
+
+{
+
+
+/*
+ *
+ * Responsible for making sure the PostScript color procedures are downloaded from
+ * *colorfile. Done at most once per job, and only if the job really uses color.
+ * For now I've decided not to quit if we can't read the color file.
+ *
+ */
+
+
+ if ( gotcolor == FALSE && access(colorfile, 04) == 0 )
+ doglobal(colorfile);
+
+ if ( tf == stdout )
+ gotcolor = TRUE;
+
+} /* End of getcolor */
+
+
+/*****************************************************************************/
+
+
+void
+newcolor (
+ char *name /* of the color */
+)
+
+
+{
+
+
+ char *p; /* next character in *name */
+ int i; /* goes in color[i] */
+
+
+/*
+ *
+ * Converts *name to lower case and saves the result in color[] for use as the
+ * current color. The first time something other than DEFAULTCOLOR is requested
+ * sets wantcolor to TRUE. Characters are converted to lower case as they're put
+ * in color[] and we quit when we find a newline or get to the end of *name. The
+ * isupper() test is for Berkley systems.
+ *
+ */
+
+
+ for ( p = name; *p && (*p == ' ' || *p == ':'); p++ ) ;
+
+ for ( i = 0; i < sizeof(color) - 1 && *p != '\n' && *p; i++, p++ )
+ if ( isupper((int)*p) )
+ color[i] = tolower((int)*p);
+ else color[i] = *p;
+
+ if ( i == 0 )
+ n_strcpy(color, DEFAULTCOLOR, sizeof(color));
+ else color[i] = '\0';
+
+ if ( strcmp(color, DEFAULTCOLOR) != 0 )
+ wantcolor = TRUE;
+
+} /* End of newcolor */
+
+
+/*****************************************************************************/
+
+
+void
+setcolor(void)
+
+
+{
+
+
+ int newencoding; /* text encoding scheme that's needed */
+ char *p; /* for converting what's in color[] */
+
+
+/*
+ *
+ * Sets the color being used by the printer to whatever's stored as the current
+ * color (ie. the string in color[]). wantcolor is only set to TRUE if we've been
+ * through newcolor() and asked for something other than DEFAULTCOLOR (probably
+ * black). While in reverse video mode encoding gets set to maxencoding + 1 in
+ * dpost and 0 on the printer. Didn't see much point in trying to extend reverse
+ * video to all the different encoding schemes. realencoding is restored when we
+ * leave reverse video mode.
+ *
+ */
+
+
+ if ( wantcolor == TRUE ) {
+ endtext();
+ getcolor();
+
+ lastend = -1;
+ newencoding = realencoding;
+
+ if ( islower((int)color[0]) == 0 ) /* explicit rgb, hsb, or cmyk request */
+ fprintf(tf, "%s\n", color);
+ else {
+ putc('/', tf);
+ for ( p = color; *p && *p != ' '; p++ )
+ putc(*p, tf);
+ for ( ; *p && *p == ' '; p++ ) ;
+ if ( strncmp(p, "on ", 3) == 0 ) p += 3;
+ if ( *p != '\0' ) {
+ fprintf(tf, " /%s", p);
+ newencoding = maxencoding + 1;
+ } /* End if */
+ fprintf(tf, " _setcolor\n");
+ } /* End else */
+
+ if ( newencoding != encoding ) {
+ encoding = newencoding;
+ fprintf(tf, "%d setdecoding\n", encoding);
+ resetpos();
+ } /* End if */
+ } /* End if */
+
+} /* End of setcolor */
+
+
+/*****************************************************************************/
+
diff --git a/troff/troff.d/dpost.d/comments.h b/troff/troff.d/dpost.d/comments.h
new file mode 100644
index 000000000000..85482a030ce8
--- /dev/null
+++ b/troff/troff.d/dpost.d/comments.h
@@ -0,0 +1,161 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "comments.h 1.5 05/06/08 SMI" SVr4.0 1.1 */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)comments.h 1.5 (gritter) 8/23/05
+ */
+
+/*
+ *
+ * Currently defined file structuring comments from Adobe - plus a few others.
+ * Ones that end with a colon expect arguments, while those ending with a newline
+ * stand on their own. Truly overkill on Adobe's part and mine for including them
+ * all!
+ *
+ * All PostScript files should begin with a header that starts with one of the
+ * following comments.
+ *
+ */
+
+#define NONCONFORMING "%!PS\n"
+#define MINCONFORMING "%!PS-Adobe-\n"
+#define OLDCONFORMING "%!PS-Adobe-1.0\n"
+
+#define CONFORMING "%!PS-Adobe-3.0\n"
+#define CONFORMINGEPS "%!PS-Adobe-3.0 EPS\n"
+#define CONFORMINGQUERY "%!PS-Adobe-3.0 Query\n"
+#define CONFORMINGEXITSERVER "%!PS-Adobe-3.0 ExitServer\n"
+
+/*
+ *
+ * Header comments - immediately follow the appropriate document classification
+ * comment.
+ *
+ */
+
+#define TITLE "%%Title:"
+#define CREATOR "%%Creator:"
+#define CREATIONDATE "%%CreationDate:"
+#define FOR "%%For:"
+#define ROUTING "%%Routing:"
+#define BOUNDINGBOX "%%BoundingBox:"
+#define PAGES "%%Pages:"
+#define REQUIREMENTS "%%Requirements:"
+
+#define DOCUMENTFONTS "%%DocumentFonts:"
+#define DOCUMENTNEEDEDFONTS "%%DocumentNeededFonts:"
+#define DOCUMENTSUPPLIEDFONTS "%%DocumentSuppliedFonts:"
+#define DOCUMENTNEEDEDPROCSETS "%%DocumentNeededProcSets:"
+#define DOCUMENTSUPPLIEDPROCSETS "%%DocumentSuppliedProcSets:"
+#define DOCUMENTNEEDEDFILES "%%DocumentNeededFiles:"
+#define DOCUMENTSUPPLIEDFILES "%%DocumentSuppliedFiles:"
+#define DOCUMENTPAPERSIZES "%%DocumentPaperSizes:"
+#define DOCUMENTPAPERFORMS "%%DocumentPaperForms:"
+#define DOCUMENTPAPERCOLORS "%%DocumentPaperColors:"
+#define DOCUMENTPAPERWEIGHTS "%%DocumentPaperWeights:"
+#define DOCUMENTPRINTERREQUIRED "%%DocumentPrinterREquired:"
+#define ENDCOMMENTS "%%EndComments\n"
+#define ENDPROLOG "%%EndProlog\n"
+
+/*
+ *
+ * Body comments - can appear anywhere in a document.
+ *
+ */
+
+#define BEGINSETUP "%%BeginSetup\n"
+#define ENDSETUP "%%EndSetup\n"
+#define BEGINDOCUMENT "%%BeginDocument:"
+#define ENDDOCUMENT "%%EndDocument\n"
+#define BEGINFILE "%%BeginFile:"
+#define ENDFILE "%%EndFile\n"
+#define BEGINPROCSET "%%BeginProcSet:"
+#define ENDPROCSET "%%EndProcSet\n"
+#define BEGINBINARY "%%BeginBinary:"
+#define ENDBINARY "%%EndBinary\n"
+#define BEGINPAPERSIZE "%%BeginePaperSize:"
+#define ENDPAPERSIZE "%%EndPaperSize\n"
+#define BEGINFEATURE "%%BeginFeature:"
+#define ENDFEATURE "%%EndFeature\n"
+#define BEGINEXITSERVER "%%BeginExitServer:"
+#define ENDEXITSERVER "%%EndExitServer\n"
+#define TRAILER "%%Trailer\n"
+
+/*
+ *
+ * Page level comments - usually will occur once per page.
+ *
+ */
+
+#define PAGE "%%Page:"
+#define PAGEFONTS "%%PageFonts:"
+#define PAGEFILES "%%PageFiles:"
+#define PAGEBOUNDINGBOX "%%PageBoundingBox:"
+#define BEGINPAGESETUP "%%BeginPageSetup\n"
+#define BEGINOBJECT "%%BeginObject:"
+#define ENDOBJECT "%%EndObject\n"
+
+/*
+ *
+ * Resource requirements - again can appear anywhere in a document.
+ *
+ */
+
+#define INCLUDEFONT "%%IncludeFont:"
+#define INCLUDEPROCSET "%%IncludeProcSet:"
+#define INCLUDEFILE "%%IncludeFile:"
+#define EXECUTEFILE "%%ExecuteFile:"
+#define CHANGEFONT "%%ChangeFont:"
+#define PAPERFORM "%%PaparForm:"
+#define PAPERCOLOR "%%PaperColor:"
+#define PAPERWEIGHT "%%PaperWeight:"
+#define PAPERSIZE "%%PaperSize:"
+#define FEATURE "%%Feature:"
+#define ENDOFFILE "%%EOF\n"
+
+#define CONTINUECOMMENT "%%+"
+#define ATEND "(atend)"
+
+/*
+ *
+ * Some non-standard document comments. Global definitions are occasionally used
+ * in dpost and are marked by BEGINGLOBAL and ENDGLOBAL. The resulting document
+ * violates page independence, but can easily be converted to a conforming file
+ * using a utililty program.
+ *
+ */
+
+#define BEGINSCRIPT "%%BeginScript\n"
+#define BEGINGLOBAL "%%BeginGlobal\n"
+#define ENDGLOBAL "%%EndGlobal\n"
+#define ENDPAGE "%%EndPage:"
+#define FORMSPERPAGE "%%FormsPerPage:"
+#define CREATOR "%%Creator:"
+#define CREATIONDATE "%%CreationDate:"
+
diff --git a/troff/troff.d/dpost.d/dpost.1 b/troff/troff.d/dpost.d/dpost.1
new file mode 100644
index 000000000000..7a935f823d03
--- /dev/null
+++ b/troff/troff.d/dpost.d/dpost.1
@@ -0,0 +1,258 @@
+.\"
+.\" CDDL HEADER START
+.\"
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.\"
+.\" CDDL HEADER END
+.\" Copyright 1989 AT&T Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
+.\"
+.\" Portions Copyright (c) 2007 Gunnar Ritter, Freiburg i. Br., Germany
+.\"
+.\" Sccsid @(#)dpost.1 1.11 (gritter) 2/7/07
+.\"
+.\" from OpenSolaris dpost 1 "9 Sep 1996" "SunOS 5.11" "User Commands"
+.TH DPOST 1 "2/7/07" "Heirloom Documentation Tools" "User Commands"
+.SH NAME
+dpost \- troff postprocessor for PostScript printers
+.SH SYNOPSIS
+.HP
+.ad l
+.nh
+\fBdpost\fR
+[\fB\-c\fR\ \fInum\fR]
+[\fB\-e\fR\ \fInum\fR]
+[\fB\-m\fR\ \fInum\fR]
+[\fB\-n\fR\ \fInum\fR]
+[\fB\-o\fR\ \fIlist\fR]
+[\fB\-p\fR\ \fImode\fR]
+[\fB\-w\fR\ \fInum\fR]
+[\fB\-x\fR\ \fInum\fR]
+[\fB\-y\fR\ \fInum\fR]
+[\fB\-F\fR\ \fIdir\fR]
+[\fB\-H\fR\ \fIdir\fR]
+[\fB\-L\fR\ \fIfile\fR]
+[\fB\-M\fR\ \fImarks\fR]
+[\fB\-O\fR]
+[\fB\-T\fR \fIname\fR]
+[\fIfile\fR] .\|.\|.
+.br
+.ad b
+.hy 1
+.SH DESCRIPTION
+\fIdpost\fR translates \fIfiles\fR created by
+\fItroff\fR(1)
+into PostScript and writes the results on the standard output.
+If no
+\fIfiles\fR are specified, or if \- is one of the input \fIfiles\fR,
+the standard input
+is read.
+The following options are accepted:
+.TP 15
+\fB\-c\fR\fI num\fR
+Print \fInum\fR copies of each page.
+By default
+only one copy is printed.
+.TP
+\fB\-e\fR\fI num\fR
+Sets the text encoding level to \fInum\fR.
+The recognized choices are
+digits between 0 and 5.
+\fB0\fR uses the PostScript \fBashow\fR operator, and produces
+output essentially identical to previous versions of \fIdpost\fR.
+\fB1\fR also uses \fBashow\fR but integrates motion commands
+with text commands.
+\fB2\fR uses the PostScript \fBawidthshow\fR operator,
+computing space widths in PostScript.
+\fB3\fR also uses \fBawidthshow\fR
+but computes space widths in \fIdpost\fR.
+\fB4\fR uses \fBashow\fR, storing position as differences.
+\fB5\fR emits the same commands as 4
+but in a binary PostScript Level 2 representation.
+The default is 3 with the \fBps\fR device.
+.TP
+\fB\-m\fR\fI num\fR
+Magnify each logical page by the factor \fInum\fR.
+Pages are scaled
+uniformly about the origin,
+which is located near the upper left corner of each page.
+The default
+magnification is \fB1.0\fR.
+.TP
+\fB\-n\fR\fI num\fR
+Print \fInum\fR logical pages on each piece of paper, where \fInum\fR
+can be any positive integer.
+By default, \fInum\fR is set to \fB1\fR.
+.TP
+\fB\-o\fR\fI list\fR
+Print those pages for which numbers are given in the comma-separated
+\fIlist\fR.
+The list
+contains single numbers \fIN\fR and ranges \fIN1\fR\fB\(mi\fR\fIN2.\fR
+A missing \fIN1\fR means the lowest
+numbered page, a missing \fIN2\fR means the highest.
+The page range is
+an expression of logical pages rather than physical sheets of paper.
+For example, if you are printing two logical
+pages to a sheet, and you specified a range of \fB4\fR, then two sheets
+of paper would print, containing four page layouts.
+If you specified a
+page range of \fB3-4\fR, when requesting
+two logical pages to a sheet; then \fIonly\fR page 3 and page 4 layouts
+would print, and they would appear on one physical sheet of paper.
+.TP
+\fB\-p\fR\fI mode\fR
+Print \fIfiles\fR in either \fBportrait\fR or \fBlandscape\fR \fImode\fR.
+Only
+the first character of \fImode\fR is significant.
+The default
+\fImode\fR is portrait.
+.TP
+\fB\-w\fR\fI num\fR
+Set the line width used to implement \fItroff\fR graphics commands to
+\fInum\fR
+points, where a point is approximately 1/72 of an inch.
+By default,
+\fInum\fR is set to \fB0.3\fR points.
+.TP
+\fB\-x\fR\fI num\fR
+Translate the origin \fInum\fR inches along the positive x axis.
+The
+default coordinate system
+has the origin fixed near the upper left corner of the page, with
+positive x to the right and positive y down the page.
+Positive
+\fInum\fR moves everything right.
+The default offset
+is \fB0\fR inches.
+.TP
+\fB\-y\fR\fI num\fR
+Translate the origin \fInum\fR inches along the positive y axis.
+Positive \fInum\fR moves text up the page.
+The default offset is
+\fB0\fR.
+.TP
+\fB\-F\fR\fI dir\fR
+Use \fIdir\fR as the font directory.
+The default \fIdir\fR is
+\fB/usr/ucblib/doctools/font\fR, and \fIdpost\fR reads binary font files from
+directory \fB/usr/ucblib/doctools/font/devps\fR.
+.TP
+\fB\-H\fR\fI dir\fR
+Use \fIdir\fR as the host resident font directory.
+Files in this
+directory should be complete
+PostScript font descriptions, and must be assigned a name that
+corresponds to the appropriate two-character \fItroff\fR font name.
+Each font file is copied to the output file only when needed
+and at most once during each job.
+There is no default directory.
+.TP
+\fB\-L\fR\fI file\fR
+Use \fIfile\fR as the PostScript prologue which, by default, is
+\fB/usr/lib/lp/postscript/dpost.ps\fR.
+.TP
+\fB\-M \fImarks\fR
+Print marks (in combination with the \fB\%trimat\fR \fItroff\fR request).
+Valid types of \fImarks\fR are:
+\fB\%cutmarks\fR,
+\fB\%registrationmarks\fR,
+\fB\%startargets\fR,
+\fB\%colorbars\fR,
+and
+\fB\%all\fR.
+Mark names can be abbreviated and combined by colons,
+e.g. \fB\-Mcut:reg\fR will print cut marks and registration marks.
+.TP
+\fB\-O\fR
+Disables PostScript picture inclusion.
+A recommended option when
+\fIdpost\fR is run by a spooler in a networked environment.
+.TP
+\fB\-T\fR\fI name\fR
+Use font files for device \fIname\fR as the best description of
+available PostScript fonts.
+By default, \fIname\fR is set to \fBps\fR and \fIdpost\fR reads
+files from \fB/usr/ucblib/doctools/font/devps\fR.
+.PP
+The \fIfiles\fR should be prepared by \fItroff\fR.
+The default font
+files in \fB/usr/ucblib/doctools/font/devps\fR produce the best output.
+They assume a resolution of 72000 dpi, and can be used to format files by
+adding the \fB\-Tps\fR option to the \fItroff\fR call.
+.PP
+\fIdpost\fR makes no assumptions about resolutions.
+The first
+\fBx\ res\fR command sets the resolution used to translate the input
+\fIfiles\fR, the \fBDESC\fR file, usually
+\fB/usr/ucblib/doctools/font/devps/DESC\fR,
+defines the resolution used in
+the binary font files, and the PostScript prologue is responsible for
+setting up an appropriate
+user coordinate system.
+.SH EXAMPLES
+.HP
+\fBpic \fR\fBfile\fR\fB | tbl | eqn | troff \fR\fB\-mm\fR\fB
+\fR\fB\-Tps\fR\fB | dpost\fR
+.SH FILES
+/usr/ucblib/doctools/font/devps/*
+.br
+/usr/ucblib/doctools/font/devpost/charlib/*
+.br
+/usr/ucblib/doctools/font/devpost/postscript/dpost.ps
+.br
+/usr/ucblib/doctools/font/devpost/postscript/color.ps
+.br
+/usr/ucblib/doctools/font/devpost/postscript/cutmarks.ps
+.br
+/usr/ucblib/doctools/font/devpost/postscript/draw.ps
+.br
+/usr/ucblib/doctools/font/devpost/postscript/forms.ps
+.br
+/usr/ucblib/doctools/font/devpost/postscript/ps.requests
+.br
+/usr/ucblib/doctools/tmac/pictures
+.br
+/usr/ucblib/doctools/tmac/color
+.SH SEE ALSO
+troff(1)
+.SH DIAGNOSTICS
+The following exit values are returned:
+.TP 10
+\fB\fB0\fR\fR
+Successful completion.
+.TP
+\fBnon-zero\fR
+An error occurred.
+.SH NOTES
+Although \fIdpost\fR can handle files formatted for any device,
+emulation is expensive and can easily double the print time and the
+size of the output file.
+No attempt has been made to
+implement the character sets or fonts available on all devices
+supported by \fItroff\fR.
+Missing characters will be replaced by white
+space, and unrecognized fonts will usually default to one
+of the Times fonts (that is, \fBR\fR, \fBI\fR, \fBB\fR, or \fBBI\fR).
+.PP
+An \fBx res\fR command must precede the first \fBx init\fR command,
+and all the input \fIfiles\fR should have been prepared for the same
+output device.
+.PP
+Use of the \fB\-T\fR option is not encouraged.
+Its only purpose is to
+enable the use of other PostScript font and device description files,
+that perhaps use different resolutions, character
+sets, or fonts.
diff --git a/troff/troff.d/dpost.d/dpost.c b/troff/troff.d/dpost.d/dpost.c
new file mode 100644
index 000000000000..f27d33cbd4f8
--- /dev/null
+++ b/troff/troff.d/dpost.d/dpost.c
@@ -0,0 +1,4836 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/* from OpenSolaris "dpost.c 1.11 05/06/08 SMI" SVr4.0 1.2 */
+
+/*
+ * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
+ *
+ * Sccsid @(#)dpost.c 1.176 (gritter) 8/19/08
+ */
+
+/*
+ *
+ * dpost - troff post-processor for PostScript printers.
+ *
+ * A program that translates output generated by the device independent troff
+ * into PostScript. Much was borrowed from dimpress and dps (formally dlzw),
+ * and even though the code has been changed, credit has to be given to Richard
+ * Flood for his early work on the PostScript driver.
+ *
+ * Among the most interesting new features are color support (see devcntrl() and
+ * file color.c) and code to handle complex paths pieced together using any of the
+ * standard drawing commands (see devcntrl() and file draw.c). Reverse video mode
+ * has also been included as a special case of the color support. Two encoding
+ * schemes based on widthshow are also new additions. The safe one is obtained when
+ * you set encoding to 2 (eg. using the -e2 option). The slightly faster method
+ * is obtained by setting encoding to 3 (eg. using the -e3 option), although it's
+ * not recommended. Rounding errors in character widths can accumulate and become
+ * quite noticeable by the time you get to the right margin. More often than not
+ * you end up getting a ragged right margin.
+ *
+ * The program handles files formatted for any device, although the best and
+ * most efficient output is generated when the font and description files match
+ * PostScript's resident fonts. Device emulation is relatively expensive, and
+ * can produce output files that are more than twice the size of the input files.
+ * In most cases output files will be smaller than input files, perhaps by up to
+ * 40 percent, although the results you get depend on what you're doing and the
+ * text encoding you're using. You'll get the worst results if you're emulating
+ * another device, using special bitmap characters, like the logo, or doing lots
+ * of vertical motion or drawing.
+ *
+ * PostScript fonts don't support all of troff's characters, so some have to
+ * be built by special PostScript procedures. Those routines can be found in
+ * *fontdir/devpost/charlib, and are only used when we try to print a character
+ * that has been assigned a code less than 32. Definitions are only made the
+ * first time each character is used. Subsequent requests to print the character
+ * only generate a call to the PostScript procedure that's been copied to the
+ * output file. For example you'll find a file called sq in directory
+ * *fontdir/devpost/charlib. It defines a PostScript procedure called build_sq
+ * that's called whenever we need to print a square. Special characters that
+ * have been assigned a code of 2 are expected to come in two pieces. The
+ * definition part and bitmap part (or whatever). The definition is only made
+ * once, but the contents of the character's .map file are copied to the output
+ * file each time, immediately after charlib() generates the call to the
+ * PostScript procedure (build_?? ) that builds the character. That's typically
+ * how logos built from bitmaps would be handled.
+ *
+ * Several different methods can be used to encode lines of text. What's done
+ * depends on the value assigned to encoding. Print time should decrease as
+ * encoding increases (up to MAXENCODING). Setting encoding to 0, which should
+ * probably be the default, produces output essentially identical to the original
+ * version of dpost. It's the slowest but most stable method of encoding lines of
+ * text, and won't be bothered by rounding errors in the font width tables that
+ * could become noticeable by the time you get to the end of a line. Other schemes
+ * seem to work, but aren't well tested and are not guaranteed for all possible
+ * jobs. encoding can be changed on the command line using the -e option. Part of
+ * the support for different encoding schemes was to move control of all text
+ * related output to separate routines. It makes dpost work harder, but changing
+ * things is easy. For example adding stuff to support widthshow took less than
+ * an hour.
+ *
+ * I've also added code that handles the DOCUMENTFONTS comment, although it's
+ * only produced for those fonts in directory /usr/lib/font/devpost that have an
+ * associated .name file. The first string in a .name file should be the (long)
+ * PostScript name (eg. Times-Roman in R.name). For now everything else in the
+ * .name file is ignored, although that may also change. You'll find .name files
+ * for all the supported fonts in the devpost source directory, although they may
+ * not be installed in /usr/lib/font/devpost.
+ *
+ * The PostScript prologue is copied from *prologue before any of the input files
+ * are translated. The program expects the following procedures are avaliable:
+ *
+ * setup
+ *
+ * mark ... setup -
+ *
+ * Handles special initialization stuff that depends on how the program
+ * was called. Expects to find a mark followed by key/value pairs on the
+ * stack. The def operator is applied to each pair up to the mark, then
+ * the default state is set up. An 'x res' command must preceed the
+ * 'x init' command!
+ *
+ * pagesetup
+ *
+ * page pagesetup -
+ *
+ * Called at the start of each page, immediately after the page level
+ * save, to do special initialization on a per page basis. Right now the
+ * only argument is the current page number, and actually nothing of any
+ * importance is currently done.
+ *
+ * setdecoding
+ *
+ * num setdecoding -
+ *
+ * Selects the text decoding procedure (ie. what's assigned to PostScript
+ * procedure t) from the decodingdefs array defined in the prologue. num
+ * should be the value assigned to variable encoding (in dpost) and will
+ * remain constant throughout a job, unless special features, like reverse
+ * video printing, are requested. The text encoding scheme can be set on
+ * the command line using the -e option. Print time and the size of the
+ * output file will usually decrease as the value assigned to encoding
+ * increases.
+ *
+ * f
+ *
+ * size font f -
+ *
+ * Selects the size and font to be used for character imaging. Font names
+ * are defined, in *prologue, so they agree with the one or two character
+ * names used by troff.
+ *
+ * m
+ *
+ * x y m -
+ *
+ * Moves to point (x, y). Normally only used when the vertical position
+ * changes. Horizontal positioning between words (or letters) is handled
+ * in procedure t (below).
+ *
+ * t
+ *
+ * mark text t mark
+ *
+ * Processes everything on the stack, up to the mark, as a single line
+ * of text to be printed at a fixed vertical position. What's put out as
+ * text depends on the encoding scheme. Setting encoding to 0 produces
+ * output essentially identical to the original version of dpost. In that
+ * case everything on the stack, up to a mark, is interpreted (from top
+ * down) as an absolute horizontal position and a string to be printed at
+ * that point. For example the stack might look like,
+ *
+ * mark(this)1000(is)1100(an)1200(example)1300 t
+ *
+ * Procedure t would go through the stack, up to the mark, adjusting the
+ * horizontal position before printing each string. In other encoding
+ * schemes, like the one based on widthshow, strings containing several
+ * space separated words would appear on the stack, and each one would be
+ * preceeded by a number that's expected to be added to the width of a
+ * space. For example we might have,
+ *
+ * mark(an example)30(this is)40 2 1000 2000 t
+ *
+ * where (1000, 2000) is where the first string starts and 2 is the repeat
+ * count (ie. number of string and space pairs on the stack).
+ *
+ * w
+ *
+ * string x y w -
+ *
+ * Prints a single word starting at position (x, y). Only used in the more
+ * complicated encoding schemes (eg. the ones based on widthshow).
+ *
+ * done
+ *
+ * Makes sure the last page is printed. Only needed when we're printing
+ * more than one page on each sheet of paper.
+ *
+ * The PostScript procedures that support troff's drawing commands have been moved
+ * out of *prologue and put in a separate file (ie. DRAW as defined in path.h).
+ * The procedures are used by the routines in file draw.c, and are copied to the
+ * prologue.
+ *
+ * Many default values, like the magnification and orientation, are defined in
+ * the prologue, which is where they belong. If they're changed (by options), an
+ * appropriate definition is made after the prologue is added to the output file.
+ * The -P option passes arbitrary PostScript through to the output file. Among
+ * other things it can be used to set (or change) values that can't be accessed by
+ * other options.
+ *
+ *
+ * output language from troff:
+ * all numbers are character strings
+ *
+ * sn size in points
+ * fn font as number from 1-n
+ * cx ascii character x
+ * Cxyz funny char xyz. terminated by white space
+ * Hn go to absolute horizontal position n
+ * Vn go to absolute vertical position n (down is positive)
+ * hn go n units horizontally (relative)
+ * vn ditto vertically
+ * nnc move right nn, then print c (exactly 2 digits!)
+ * (this wart is an optimization that shrinks output file size
+ * about 35% and run-time about 15% while preserving ascii-ness)
+ * Dt ...\n draw operation 't':
+ * Dl x y line from here by x,y
+ * Dc d circle of diameter d with left side here
+ * De x y ellipse of axes x,y with left side here
+ * Da x1 y1 x2 y2 arc counter-clockwise from current point (x, y) to
+ * (x + x1 + x2, y + y1 + y2)
+ * D~ x y x y ... wiggly line by x,y then x,y ...
+ * nb a end of line (information only -- no action needed)
+ * b = space before line, a = after
+ * p new page begins -- set v to 0
+ * #...\n comment
+ * x ...\n device control functions:
+ * x i init
+ * x T s name of device is s
+ * x r n h v resolution is n/inch
+ * h = min horizontal motion, v = min vert
+ * x p pause (can restart)
+ * x s stop -- done forever
+ * x t generate trailer
+ * x f n s font position n contains font s
+ * x H n set character height to n
+ * x S n set slant to N
+ *
+ * Subcommands like "i" are often spelled out like "init".
+ *
+ *
+ *
+ * To get dpost output conforming to Adobe's structuring conventions (DSC),
+ * all output is accumulated in temporary files first. When the document is
+ * completed, files that contain global data are output first, followed by
+ * regular commands, all surrounded by DSC comments. Speed problems, which
+ * were the reason why this was not done by previous versions of dpost, are
+ * no longer of concern in 2005 since several hundred pages of text are
+ * processed now in less than a second.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <math.h>
+#include <ctype.h>
+#include <time.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdarg.h>
+
+#include "comments.h" /* PostScript file structuring comments */
+#include "gen.h" /* general purpose definitions */
+#include "path.h" /* for the prologue and a few other files */
+#include "ext.h" /* external variable definitions */
+#include "dev.h" /* typesetter and font descriptions */
+#include "dpost.h" /* a few definitions just used here */
+#include "asciitype.h"
+#include "afm.h"
+#include "fontmap.h"
+
+
+#if defined (__GLIBC__) && defined (_IO_getc_unlocked)
+#undef getc
+#define getc(f) _IO_getc_unlocked(f)
+#endif
+#if defined (__GLIBC__) && defined (_IO_putc_unlocked)
+#undef putc
+#define putc(c, f) _IO_putc_unlocked(c, f)
+#endif
+
+
+char *progname;
+char *prologue = DPOST; /* the basic PostScript prologue */
+char *colorfile = COLOR; /* things needed for color support */
+char *drawfile = DRAW; /* and drawing */
+char *cutmarksfile = CUTMARKS;
+char *formfile = FORMFILE; /* stuff for multiple pages per sheet */
+char *baselinefile = BASELINE;
+
+char *fontdir = FONTDIR; /* binary device directories found here */
+char *hostfontdir = NULL; /* host resident font directory */
+
+int formsperpage = 1; /* page images on each piece of paper */
+int copies = 1; /* and this many copies of each sheet */
+int picflag = ON; /* enable/disable picture inclusion */
+
+
+/*
+ *
+ * encoding selects the encoding scheme used to output lines of text. Change it
+ * to something other than 0 at your own risk. The other methods seem to work but
+ * aren't well tested and are not guaranteed. Some special features, like reverse
+ * video, may temporarily change the encoding scheme and reset it to realencoding
+ * when done.
+ *
+ * Encoding 4 is new as of 9/8/05. It stores only the distances between words and
+ * thus saves a bit of output size. It is automatically enabled at high resolutions.
+ *
+ */
+
+
+int encoding = DFLTENCODING;
+int realencoding = DFLTENCODING;
+int maxencoding = MAXENCODING;
+int eflag;
+
+int LanguageLevel; /* PostScript output language level */
+static int Binary; /* PostScript output contains binary data */
+
+/*
+ *
+ * seenfonts[] keeps track of the fonts we've used, based on internal numbers. It
+ * helps manage host resident fonts and the DOCUMENTFONTS comment, but only works
+ * if all fonts have internal numbers less than MAXINTERNAL. *docfonts counts the
+ * number of font names we've recorded in *temp_file. If it's positive routine
+ * done() adds *temp_file to the output file before quitting.
+ *
+ */
+
+
+char seenfonts[MAXINTERNAL+1];
+int docfonts = 0;
+struct afmtab **afmfonts;
+int afmcount = 0;
+
+/*
+ *
+ * devname[] is the device troff used when the job was formatted, while *realdev
+ * is combined with *fontdir and used to locate the font and device tables that
+ * that control the translation of the input files into PostScript. *realdev can
+ * be changed using the -T option, but if you do you may end up getting garbage.
+ * The character code field must agree with PostScript's font encoding and font
+ * names must be properly mapped into PostScript font names in the prologue.
+ *
+ */
+
+
+#define devname troff_devname
+char devname[20] = ""; /* job is formatted for this printer */
+char *realdev = DEVNAME; /* a good description of target printer */
+
+
+/*
+ *
+ * Standard things that come from binary font and description files for *realdev.
+ * Most are initialized in fontinit() or loadfont().
+ *
+ */
+
+
+struct dev dev; /* DESC starts this way */
+struct Font **fontbase; /* FONT files begin this way */
+int *pstab; /* list of available sizes */
+int nsizes = 1; /* and the number of sizes in that list */
+int smnt; /* index of first special font */
+int nchtab; /* number of special character names */
+int fsize; /* max size of a font files in bytes */
+int unitwidth; /* set to dev.unitwidth */
+char *chname; /* special character strings */
+short *chtab; /* used to locate character names */
+unsigned short **fitab; /* locates char info on each font */
+int **fontab; /* character width data for each font */
+unsigned short **codetab; /* and codes to get characters printed */
+char **kerntab; /* for makefont() */
+
+
+/*
+ *
+ * Special characters missing from standard PostScript fonts are defined by files
+ * in directory *fontdir/devpost/charlib. Files have the same names as the troff
+ * special character names (for now at least) and each one defines a PostScript
+ * procedure that begins with the prefix build_ and ends with the character's
+ * name.
+ *
+ * For example, the routine used to build character \(12, would be build_12.
+ * downloaded[] points to an array, allocated in fontinit(), that keeps track of
+ * the characters that have already been defined - so we only do it once.
+ *
+ */
+
+
+char *downloaded; /* nonzero means it's been downloaded */
+
+
+/*
+ *
+ * Variables that keep track of troff's requests. All are set from values in the
+ * input files. nfonts is adjusted in t_fp() as new fonts are mounted.
+ *
+ */
+
+
+int nfonts = 0; /* number of font positions */
+int size = 1; /* current size - internal value */
+#define FRACTSIZE -23 /* if size == FRACTSIZE then ... */
+float fractsize = 0; /* fractional point size */
+int font = 0; /* font position we're using now */
+int subfont = 0; /* extra encoding vector */
+int hpos = 0; /* where troff wants to be - horizontally */
+int vpos = 0; /* same but vertically */
+float lastw = 0; /* width of the last input character */
+int track = 0; /* tracking hint from troff */
+int lasttrack = 0; /* previous tracking hint */
+int tracked; /* records need to flush track */
+int lastc = 0; /* and its name (or index) */
+
+int res; /* resolution assumed in input file */
+float widthfac = 1.0; /* for emulation = res/dev.res */
+float horscale = 1.0; /* horizontal font scaling */
+float lasthorscale = 1.0; /* last horizontal font scaling */
+int wordspace = 0; /* w command was last */
+
+
+/*
+ *
+ * Remember some of the same things, but this time for the printer. lastend is only
+ * used when we're doing reverse video, and is where the last character on the
+ * current line was printed.
+ *
+ */
+
+
+int lastsize = -1; /* last internal size we used */
+float lastfractsize = -1; /* last fractional size */
+int lastfont = -1; /* last font we told printer about */
+int lastsubfont = -1; /* last extra encoding vector */
+float lastx = -1; /* printer's current position */
+int lasty = -1;
+int savey = -1;
+int lastend; /* where last character on this line was */
+
+
+/*
+ *
+ * fontname[] keeps track of the mounted fonts. Filled in (by t_fp()) from data
+ * in the binary font files.
+ *
+ * When font metrics are directly read from AFM files, all characters that
+ * are not ASCII are put into the remaining positions in PostScript encoding
+ * vectors. Their position in these vectors in recorded in afm->encmap, and
+ * characters from troff are translated if necessary.
+ *
+ */
+
+
+struct {
+
+ struct afmtab *afm; /* AFM data, if any */
+ char *name; /* name of the font loaded here */
+ int number; /* its internal number */
+ float fontheight; /* points from x H ... */
+ int fontslant; /* angle from x S ... */
+
+
+} fontname[NFONT+1];
+
+
+/*
+ *
+ * All the special fonts will be mounted after the last legitimate font position.
+ * It helps when we're translating files prepared for devices, like the 202, that
+ * have a different set of special fonts. The set of special fonts needed when
+ * *realdev's tables are used may not get mounted when we're emulating another
+ * device. gotspecial keeps track of whether we've done it yet. seenpage is set
+ * to TRUE after we've seen the first page command in the input file. It controls
+ * what's done in t_font() and is needed because nfonts is no longer set when the
+ * DESC file is read, but rather is updated from "x font" commands in the
+ * input files. gotregular ensures that at least one regular font is mounted.
+ *
+ */
+
+
+int gotspecial = FALSE;
+int gotregular = FALSE;
+int seenpage = FALSE;
+
+
+/*
+ *
+ * The amount of horizontal positioning error we accept controls both the size
+ * of the output file and the appearance of the printed text. It's probably most
+ * important when we're emulating other devices, like the APS-5. The error can be
+ * set using the -S option. It's converted from points to machine units in t_init()
+ * after the resolution is known. rvslop is also set in t_init() and only used to
+ * adjust the width of the box that's drawn around text when we're printing in
+ * reverse video mode.
+ *
+ */
+
+
+float pointslop = SLOP; /* horizontal error in points */
+int Sflag; /* unless -S gives explicit slop */
+int slop; /* and machine units */
+int rvslop; /* to extend box in reverse video mode */
+
+
+/*
+ *
+ * Characters are accumulated and saved in PostScript strings that are eventually
+ * processed by making a single call to procedure t. textcount counts the number
+ * of individual strings collected but not yet processed, and is primarily used to
+ * make sure PostScript's stack doesn't get too big. When textcount is positive
+ * we've started accumulating strings and need to generate a call to PostScript
+ * procedure t to process the text before anything else (like a font change) is
+ * done.
+ *
+ */
+
+
+int textcount = 0; /* strings accumulated so far */
+int stringstart = 0; /* where the next one starts */
+int laststrstart = INT_MIN; /* save for optimization */
+int spacecount = 0; /* spaces seen so far on current line */
+int charcount = 0; /* characters on current line */
+
+
+/*
+ *
+ * Things that can be used by text line encoding schemes that need to read and
+ * remember an entire line before doing any output. The strings that make up the
+ * line can be saved in array strings[] and accessed by fields in line[]. *strptr
+ * points to the next free slot in strings[].
+ *
+ */
+
+
+char strings[STRINGSPACE];
+char *strptr;
+Line line[MAXSTACK+3];
+
+
+/*
+ *
+ * When we're emulating another device we may want to map font name requests that
+ * come in as "x font pos name" commands into some other font name before anything
+ * else is done (ie. calling loadfont()). Font names can collide or we may just
+ * want to a mapping that depends on the device troff used to format the input
+ * files. devfontmap points to a structure that's filled in by getdevmap() if the
+ * mapping file /usr/lib/font/dev*realdev/fontmaps/devname exists. mapdevfont()
+ * then uses that table to translate font name requests into something else before
+ * loadfont() gets called.
+ *
+ * fontmap[] provides a simple minded translation that maps an unrecognized font
+ * name (in loadfont()) into another font name that we know will be available. It
+ * doesn't provide the fine control available with *devfontmap, but should be good
+ * enough for most jobs. Both structures are only needed when emulating another
+ * device using *realdev's font tables.
+ *
+ */
+
+
+Devfontmap *devfontmap = NULL; /* device level */
+Fontmap fontmap[] = FONTMAP; /* and general mapping tables - emulation */
+
+
+/*
+ *
+ * Variables and functions for the pdfmark operator.
+ *
+ */
+static char *Author; /* DOCINFO /Author */
+static char *Title; /* DOCINFO /Title */
+static char *Subject; /* DOCINFO /Subject */
+static char *Keywords; /* DOCINFO /Keywords */
+static struct Bookmark {
+ char *Title; /* OUT /Title */
+ char *title; /* unencoded title */
+ int Count; /* OUT /Count */
+ int level; /* used to generate count */
+ int closed; /* the bookmark is closed initially */
+} *Bookmarks;
+static size_t nBookmarks;
+static double pagelength = 792; /* lenght of page in points */
+#define MAXBOOKMARKLEVEL 20
+
+static void orderbookmarks(void);
+
+static struct box {
+ int val[4];
+ int flag;
+} mediasize, bleedat, trimat, cropat;
+
+/*
+ *
+ * For the -M option.
+ *
+ */
+
+static enum {
+ M_NONE = 000,
+ M_CUT = 001,
+ M_STAR = 002,
+ M_REG = 004,
+ M_COL = 010,
+ M_ALL = 077
+} Mflag;
+
+static void setmarks(char *);
+
+
+/*
+ *
+ * A few variables that are really only used if we're doing accounting. Designed
+ * for our use at Murray Hill and probably won't suit your needs. Changes should
+ * be easy and can be made in routine account().
+ *
+ */
+
+
+int printed = 0; /* charge for this many pages */
+
+
+/*
+ *
+ * Output and accounting file definitions. The PostScript output always goes to
+ * stdout or /dev/null, while the accounting file can be selected using the -A
+ * option.
+ *
+ */
+
+
+FILE *tf = NULL; /* PostScript output goes here */
+FILE *gf = NULL; /* global data goes here */
+FILE *rf = NULL; /* resource data goes here */
+FILE *sf = NULL; /* supplied resource comments go here */
+FILE *nf = NULL; /* needed resource comments go here */
+FILE *pf = NULL; /* elements of _custompagesetup */
+int sfcount; /* count of supplied resources */
+int nfcount; /* count of needed resources */
+int ostdout; /* old standard output */
+FILE *fp_acct = NULL; /* accounting stuff written here */
+
+
+/*
+ *
+ * Very temporary space that can be used to do things like building up pathnames
+ * immediately before opening a file. Contents may not be preserved across calls
+ * to subroutines defined in this file, so it probably should only be used in low
+ * level subroutines like loadfont() or fontinit() and nowhere else.
+ *
+ */
+
+
+char temp[4096];
+
+/*****************************************************************************/
+
+static char *linkborderstyle;
+static char *ulinkborderstyle;
+
+static void sethorscale(char *);
+static void t_papersize(char *);
+static void t_cutat(const char *, struct box *, char *);
+static void t_track(char *);
+static void t_strack(void);
+static void t_pdfmark(char *);
+static void t_locale(char *);
+static void t_anchor(char *);
+static void t_link(char *);
+static void t_linkcolor(char *);
+static void t_linkborder(char *);
+static void t_ulink(char *);
+static void t_ulinkcolor(char *);
+static void t_ulinkborder(char *);
+static char *t_linkborderstyle(char *);
+
+static int mb_cur_max;
+
+/*****************************************************************************/
+
+
+int
+main(int agc, char *agv[])
+
+
+{
+ const char template[] = "/var/tmp/dpostXXXXXX";
+ char *tp;
+ FILE *fp;
+
+
+/*
+ *
+ * A program that translates troff output into PostScript. All the input files
+ * must have been formatted for the same device, which doesn't necessarily have to
+ * be *realdev. If there's more than one input file, each begins on a new page.
+ *
+ */
+
+ setlocale(LC_CTYPE, "");
+ mb_cur_max = MB_CUR_MAX;
+
+ ostdout = dup(1);
+ if (close(mkstemp(tp = strdup(template))) < 0 ||
+ freopen(tp, "r+", stdout) == NULL) {
+ perror(tp);
+ return 2;
+ }
+ unlink(tp);
+ if (close(mkstemp(tp = strdup(template))) < 0 ||
+ (gf = fopen(tp, "r+")) == NULL) {
+ perror(tp);
+ return 2;
+ }
+ unlink(tp);
+ if (close(mkstemp(tp = strdup(template))) < 0 ||
+ (rf = fopen(tp, "r+")) == NULL) {
+ perror(tp);
+ return 2;
+ }
+ unlink(tp);
+ if (close(mkstemp(tp = strdup(template))) < 0 ||
+ (sf = fopen(tp, "r+")) == NULL) {
+ perror(tp);
+ return 2;
+ }
+ unlink(tp);
+ if (close(mkstemp(tp = strdup(template))) < 0 ||
+ (nf = fopen(tp, "r+")) == NULL) {
+ perror(tp);
+ return 2;
+ }
+ unlink(tp);
+ if (close(mkstemp(tp = strdup(template))) < 0 ||
+ (pf = fopen(tp, "r+")) == NULL) {
+ perror(tp);
+ return 2;
+ }
+ unlink(tp);
+
+ argc = agc; /* global so everyone can use them */
+ argv = agv;
+
+ progname =
+ prog_name = argv[0]; /* just for error messages */
+
+ init_signals(); /* sets up interrupt handling */
+ options(); /* command line options */
+ arguments(); /* translate all the input files */
+ done(); /* add trailing comments etc. */
+
+ fp = fdopen(ostdout, "w");
+ header(fp); /* PostScript file structuring comments */
+
+ account(); /* job accounting data */
+ return(x_stat); /* everything probably went OK */
+
+} /* End of main */
+
+/*****************************************************************************/
+int
+putint(int n, FILE *fp)
+{
+ char buf[20];
+ int c = 0, i;
+
+/*
+ *
+ * Print an integer in PostScript binary token representation.
+ *
+ */
+ if (n >= -128 && n <= 127) {
+ buf[c++] = 136;
+ buf[c++] = n;
+ } else if (n >= -32768 && n <= 32767) {
+ buf[c++] = 134;
+ buf[c++] = (n&0xff00) >> 8;
+ buf[c++] = (n&0x00ff);
+ } else {
+ buf[c++] = 132;
+ buf[c++] = (n&0xff000000) >> 24;
+ buf[c++] = (n&0x00ff0000) >> 16;
+ buf[c++] = (n&0x0000ff00) >> 8;
+ buf[c++] = (n&0x000000ff);
+ }
+ for (i = 0; i < c; i++)
+ putc(buf[i]&0377, fp);
+ return c;
+}
+
+int
+putstring1(const char *sp, int n, FILE *fp)
+{
+/*
+ *
+ * Print a string in PostScript binary token representation.
+ *
+ */
+ putc(142, fp);
+ putc(n, fp);
+ fwrite(sp, 1, n, fp);
+ return n + 2;
+}
+
+int
+putstring(const char *sp, int n, FILE *fp)
+{
+ int c = 0, m;
+
+ do {
+ m = n > 250 ? 250 : n;
+ c += putstring1(sp, m, fp);
+ sp += m;
+ n -= m;
+ } while (n > 0);
+ return c;
+}
+
+/*****************************************************************************/
+
+
+void
+init_signals(void)
+
+
+{
+
+
+ void interrupt(int); /* signal handler */
+
+
+/*
+ *
+ * Make sure we handle interrupts.
+ *
+ */
+
+
+ if ( signal(SIGINT, interrupt) == SIG_IGN ) {
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGHUP, SIG_IGN);
+ } else {
+ signal(SIGHUP, interrupt);
+ signal(SIGQUIT, interrupt);
+ } /* End else */
+
+ signal(SIGTERM, interrupt);
+
+} /* End of init_signals */
+
+
+/*****************************************************************************/
+static char *
+pdfdate(time_t *tp, char *buf, size_t size)
+{
+ struct tm *tmptr;
+ int tzdiff, tzdiff_hour, tzdiff_min;
+
+ tzdiff = *tp - mktime(gmtime(tp));
+ tzdiff_hour = (int)(tzdiff / 60);
+ tzdiff_min = tzdiff_hour % 60;
+ tzdiff_hour /= 60;
+ tmptr = localtime(tp);
+ if (tmptr->tm_isdst > 0)
+ tzdiff_hour++;
+ snprintf(buf, size, "(D:%04d%02d%02d%02d%02d%02d%+03d'%02d')",
+ tmptr->tm_year + 1900,
+ tmptr->tm_mon + 1, tmptr->tm_mday,
+ tmptr->tm_hour, tmptr->tm_min, tmptr->tm_sec,
+ tzdiff_hour, tzdiff_min);
+ return buf;
+}
+/*****************************************************************************/
+
+static void
+pdfbox(const char *boxname, struct box *bp, FILE *fp, int perpage)
+{
+ double llx, lly, urx, ury;
+
+ if (bp->flag == 0)
+ return;
+ llx = bp->val[0] * 72.0 / res;
+ lly = pagelength - ((bp->val[1] + bp->val[3]) * 72.0 / res);
+ urx = (bp->val[0] + bp->val[2]) * 72.0 / res;
+ ury = pagelength - (bp->val[1] * 72.0 / res);
+ fprintf(gf, "/_%s [%g %g %g %g] def\n",
+ boxname, llx, lly, urx, ury);
+ if (perpage)
+ fprintf(fp,
+ "[ {ThisPage} 1 dict dup /%s _%s put /PUT pdfmark\n",
+ boxname, boxname);
+ else
+ fprintf(gf, "[ /%s _%s /PAGES pdfmark\n", boxname, boxname);
+}
+
+/*****************************************************************************/
+
+void
+header(FILE *fp)
+
+
+{
+
+/*
+ *
+ * Print the DSC header, followed by the data generated so far. This function
+ * is now called after all input has been processed.
+ *
+ */
+
+
+ struct Bookmark *bp;
+ time_t now;
+ int n;
+ double x = 0, y = 0;
+ char buf[4096];
+ char crdbuf[40];
+
+
+ time(&now);
+ if (mediasize.flag) {
+ x = mediasize.val[2] * 72.0 / res;
+ y = mediasize.val[3] * 72.0 / res;
+ }
+ fprintf(fp, "%s", CONFORMING);
+ fprintf(fp, "%s %s\n", CREATOR, creator);
+ fprintf(fp, "%s %s", CREATIONDATE, ctime(&now));
+ if (LanguageLevel > 1)
+ fprintf(fp, "%%%%LanguageLevel: %d\n", LanguageLevel);
+ if (Binary)
+ fprintf(fp, "%%%%DocumentData: Binary\n");
+ if ( temp_file != NULL ) {
+ if ( docfonts > 0 ) {
+ cat(temp_file, fp);
+ putc('\n', fp);
+ } /* End if */
+ unlink(temp_file);
+ } /* End if */
+ fprintf(fp, "%s %d\n", PAGES, printed);
+ if (mediasize.flag & 2)
+ fprintf(fp, "%%%%DocumentMedia: x%gy%g %g %g 0 () ()\n", x, y, x, y);
+
+ fflush(nf);
+ rewind(nf);
+ while ((n = fread(buf, 1, sizeof buf, nf)) > 0)
+ fwrite(buf, 1, n, fp);
+ fflush(sf);
+ rewind(sf);
+ while ((n = fread(buf, 1, sizeof buf, sf)) > 0)
+ fwrite(buf, 1, n, fp);
+ fprintf(fp, "%s", ENDCOMMENTS);
+
+ fprintf(fp, "%s\n", "%%BeginProlog");
+ if ( cat(prologue, fp) == FALSE )
+ error(FATAL, "can't read %s", prologue);
+ fflush(rf);
+ rewind(rf);
+ while ((n = fread(buf, 1, sizeof buf, rf)) > 0)
+ fwrite(buf, 1, n, fp);
+ fprintf(fp, "%s", ENDPROLOG);
+
+ fprintf(fp, "%s", BEGINSETUP);
+ fprintf(fp, "\
+[ /CreationDate %s\n\
+ /Creator (%s)\n", pdfdate(&now, crdbuf, sizeof crdbuf), creator);
+ if (Author)
+ fprintf(fp, " /Author %s\n", Author);
+ if (Title)
+ fprintf(fp, " /Title %s\n", Title);
+ if (Subject)
+ fprintf(fp, " /Subject %s\n", Subject);
+ if (Keywords)
+ fprintf(fp, " /Keywords %s\n", Keywords);
+ fprintf(fp, "/DOCINFO pdfmark\n");
+ if (Bookmarks) {
+ orderbookmarks();
+ for (bp = &Bookmarks[0]; bp < &Bookmarks[nBookmarks]; bp++) {
+ fprintf(fp, "[ /Title %s\n", bp->Title);
+ if (bp->Count)
+ fprintf(fp, " /Count %d\n", bp->closed ?
+ -bp->Count : bp->Count);
+ fprintf(fp, " /Dest /Bookmark$%d\n"
+ "/OUT pdfmark\n",
+ (int)(bp - &Bookmarks[0]));
+ }
+ }
+
+ fflush(pf);
+ rewind(pf);
+ fprintf(fp, "/_custompagesetup {\n");
+ pdfbox("TrimBox", &trimat, fp, 1);
+ pdfbox("BleedBox", &bleedat, fp, 1);
+ pdfbox("CropBox", &cropat, fp, 0);
+ while ((n = fread(buf, 1, sizeof buf, pf)) > 0)
+ fwrite(buf, 1, n, fp);
+ fprintf(fp, "} def\n");
+ fprintf(fp, "/_marks {\n");
+ if (Mflag & M_CUT)
+ fprintf(fp, "_cutmarks\n");
+ if (Mflag & M_REG)
+ fprintf(fp, "_regmarks\n");
+ if (Mflag & M_STAR)
+ fprintf(fp, "_startargets\n");
+ if (Mflag & M_COL)
+ fprintf(fp, "_colorbars\n");
+ fprintf(fp, "} def\n");
+
+ fflush(gf);
+ rewind(gf);
+ while ((n = fread(buf, 1, sizeof buf, gf)) > 0)
+ fwrite(buf, 1, n, fp);
+ if (mediasize.flag) {
+ fprintf(fp, "/pagebbox [0 0 %g %g] def\n", x, y);
+ fprintf(fp, "userdict /gotpagebbox true put\n");
+ if (mediasize.flag & 2)
+ fprintf(fp, "/setpagedevice where {pop "
+ "1 dict dup /PageSize [%g %g] put setpagedevice"
+ "} if\n", x, y);
+ }
+ fprintf(fp, "mark\n");
+
+ fflush(stdout);
+ rewind(stdout);
+ while ((n = fread(buf, 1, sizeof buf, stdout)) > 0)
+ fwrite(buf, 1, n, fp);
+
+ fprintf(fp, "%s", ENDOFFILE);
+
+} /* End of header */
+
+
+/*****************************************************************************/
+
+
+void
+options(void)
+
+
+{
+
+ const char optnames[] = "a:c:e:m:n:o:p:tw:x:y:A:C:J:F:H:L:M:OP:R:S:T:DI";
+
+ int ch; /* name returned by getopt() */
+
+
+/*
+ *
+ * Reads and processes the command line options. There are, without a doubt, too
+ * many options!
+ *
+ */
+
+
+ while ( (ch = getopt(argc, argv, optnames)) != EOF ) {
+
+ switch ( ch ) {
+
+ case 'a': /* aspect ratio */
+ fprintf(stdout, "/aspectratio %s def\n", optarg);
+ break;
+
+ case 'c': /* number of copies */
+ copies = atoi(optarg);
+ fprintf(stdout, "/#copies %s store\n", optarg);
+ break;
+
+ case 'e': /* change the encoding scheme */
+ if ( (encoding = atoi(optarg)) < 0 || encoding > MAXENCODING )
+ encoding = DFLTENCODING;
+ else
+ eflag = 1;
+ realencoding = encoding;
+ break;
+
+ case 'm': /* magnification */
+ fprintf(stdout, "/magnification %s def\n", optarg);
+ break;
+
+ case 'n': /* forms per page */
+ formsperpage = atoi(optarg);
+ fprintf(stdout, "%s %s\n", FORMSPERPAGE, optarg);
+ fprintf(stdout, "/formsperpage %s def\n", optarg);
+ break;
+
+ case 'o': /* output page list */
+ out_list(optarg);
+ break;
+
+ case 'p': /* landscape or portrait mode */
+ if ( *optarg == 'l' )
+ fprintf(stdout, "/landscape true def\n");
+ else fprintf(stdout, "/landscape false def\n");
+ break;
+
+ case 't': /* just for compatibility */
+ break;
+
+ case 'w': /* line width for drawing */
+ fprintf(stdout, "/linewidth %s def\n", optarg);
+ break;
+
+ case 'x': /* shift horizontally */
+ fprintf(stdout, "/xoffset %s def\n", optarg);
+ break;
+
+ case 'y': /* and vertically on the page */
+ fprintf(stdout, "/yoffset %s def\n", optarg);
+ break;
+
+ case 'A': /* force job accounting */
+ case 'J':
+ if ( (fp_acct = fopen(optarg, "a")) == NULL )
+ error(FATAL, "can't open accounting file %s", optarg);
+ break;
+
+ case 'C': /* copy file to straight to output */
+ if ( cat(optarg, stdout) == FALSE )
+ error(FATAL, "can't read %s", optarg);
+ break;
+
+ case 'F': /* font table directory */
+ fontdir = optarg;
+ break;
+
+ case 'H': /* host resident font directory */
+ hostfontdir = optarg;
+ break;
+
+ case 'L': /* PostScript prologue file */
+ setpaths(optarg);
+ break;
+
+ case 'M': /* print cut marks */
+ setmarks(optarg);
+ break;
+
+ case 'O': /* turn picture inclusion off */
+ picflag = OFF;
+ break;
+
+ case 'P': /* PostScript pass through */
+ fprintf(stdout, "%s\n", optarg);
+ break;
+
+ case 'R': /* special global or page level request */
+ saverequest(optarg);
+ break;
+
+ case 'S': /* horizontal position error */
+ if ( (pointslop = atof(optarg)) < 0 )
+ pointslop = 0;
+ Sflag = 1;
+ break;
+
+ case 'T': /* target printer */
+ realdev = optarg;
+ break;
+
+ case 'D': /* debug flag */
+ debug = ON;
+ tf = stdout;
+ break;
+
+ case 'I': /* ignore FATAL errors */
+ ignore = ON;
+ break;
+
+ case '?': /* don't know the option */
+ error(FATAL, "");
+ break;
+
+ default:
+ error(FATAL, "missing case for option %c", ch);
+ break;
+
+ } /* End switch */
+ } /* End while */
+
+ argc -= optind; /* get ready for non-options args */
+ argv += optind;
+
+ if (Mflag) {
+ FILE *otf = tf;
+ tf = stdout;
+ doglobal(cutmarksfile);
+ tf = otf;
+ }
+
+} /* End of options */
+
+
+/*****************************************************************************/
+
+
+void
+setpaths (
+ char *name /* string that followed the -L option */
+)
+
+
+{
+
+
+ char *path; /* start of the pathname */
+
+
+/*
+ *
+ * Extends the -L option to permit run time modification of pathnames that were
+ * fixed or didn't exist in previous versions of dpost. For example, the PostScript
+ * drawing procedures have been moved out of *prologue and put in *drawfile. The
+ * new syntax can be either -Lfile or -Lname:file. If the "name:" prefix is omitted
+ * file will be used as the prologue, otherwise name should be one of "prologue",
+ * "font", "draw", "color", or "form" and is used to select the pointer that gets
+ * set to string "file".
+ *
+ */
+
+
+ for ( path = name; *path; path++ )
+ if ( *path == ':' || *path == ' ' ) {
+ while ( *path == ':' || *path == ' ' ) path++;
+ break;
+ } /* End if */
+
+ if ( *path == '\0' ) /* didn't find a "name:" prefix */
+ path = name;
+
+ if ( path == name || strncmp(name, "prologue", strlen("prologue")) == 0 )
+ prologue = path;
+ else if ( strncmp(name, "draw", strlen("draw")) == 0 )
+ drawfile = path;
+ else if ( strncmp(name, "color", strlen("color")) == 0 )
+ colorfile = path;
+ else if ( strncmp(name, "form", strlen("form")) == 0 )
+ formfile = path;
+ else if ( strncmp(name, "baseline", strlen("baseline")) == 0 )
+ baselinefile = path;
+ else if ( strncmp(name, "cutmarks", strlen("cutmarks")) == 0 )
+ cutmarksfile = path;
+
+} /* End of setpaths */
+
+/*****************************************************************************/
+
+static int
+prefix(const char *str, const char *pfx)
+{
+ while (*pfx && *str == *pfx)
+ str++, pfx++;
+ return *str == 0;
+}
+
+static void
+setmarks(char *str)
+{
+ char *sp;
+ int c;
+
+ do {
+ for (sp = str; *sp && *sp != ':'; sp++);
+ c = *sp;
+ *sp = 0;
+ if (prefix(str, "cutmarks"))
+ Mflag |= M_CUT;
+ else if (prefix(str, "registrationmarks"))
+ Mflag |= M_REG;
+ else if (prefix(str, "startargets"))
+ Mflag |= M_STAR;
+ else if (prefix(str, "colorbars"))
+ Mflag |= M_COL;
+ else if (prefix(str, "all"))
+ Mflag |= M_ALL;
+ else
+ error(FATAL, "unknown mark: -M %s", str);
+ *sp = c;
+ str = &sp[1];
+ } while (c);
+}
+
+/*****************************************************************************/
+
+
+void
+setup(void)
+
+
+{
+
+
+/*
+ * Handles things that must be done after the options are read but before the
+ * input files are processed. Called from t_init() after an "x init" command is
+ * read, because we need the resolution before we can generate the call to the
+ * setup procedure defined in *prologue. Only allowing one call to setup assumes
+ * all the input files have been prepared for the same device.
+ *
+ */
+
+
+ writerequest(0, stdout); /* global requests eg. manual feed */
+ fprintf(stdout, "/resolution %d def\n", res);
+ fprintf(stdout, "setup\n");
+ fprintf(stdout, "%d setdecoding\n", encoding);
+
+ if ( formsperpage > 1 ) { /* followed by stuff for multiple pages */
+ if ( cat(formfile, stdout) == FALSE )
+ error(FATAL, "can't read %s", formfile);
+ fprintf(stdout, "%d setupforms\n", formsperpage);
+ } /* End if */
+
+ fprintf(stdout, "%s", ENDSETUP);
+
+} /* End of setup */
+
+
+/*****************************************************************************/
+
+
+void
+arguments(void)
+
+
+{
+
+
+ FILE *fp; /* next input file */
+
+
+/*
+ *
+ * Makes sure all the non-option command line arguments are processed. If we get
+ * here and there aren't any arguments left, or if '-' is one of the input files
+ * we'll translate stdin.
+ *
+ */
+
+
+ if ( argc < 1 )
+ conv(stdin);
+ else
+ while ( argc > 0 ) {
+ if ( strcmp(*argv, "-") == 0 )
+ fp = stdin;
+ else if ( (fp = fopen(*argv, "r")) == NULL )
+ error(FATAL, "can't open %s", *argv);
+ conv(fp);
+ if ( fp != stdin )
+ fclose(fp);
+ argc--;
+ argv++;
+ } /* End while */
+
+} /* End of arguments */
+
+
+/*****************************************************************************/
+
+
+void
+done(void)
+
+
+{
+
+/*
+ *
+ * Finished with all the input files, so mark the end of the pages with a TRAILER
+ * comment, make sure the last page prints, and add things like the DOCUMENTFONTS
+ * and PAGES comments that can only be determined after all the input files have
+ * been read.
+ *
+ */
+
+
+ fprintf(stdout, "%s", TRAILER);
+ fprintf(stdout, "done\n");
+
+} /* End of done */
+
+
+/*****************************************************************************/
+
+
+void
+account(void)
+
+
+{
+
+
+/*
+ *
+ * Writes an accounting record to *fp_acct provided it's not NULL. Accounting is
+ * requested using the -A or -J options.
+ *
+ */
+
+ if ( fp_acct != NULL )
+ fprintf(fp_acct, " print %d\n copies %d\n", printed, copies);
+
+} /* End of account */
+
+
+/*****************************************************************************/
+
+void
+conv(
+
+
+ register FILE *fp /* next input file */
+)
+
+
+{
+
+
+ register int c; /* usually first char in next command */
+ int m, n, n1, m1; /* when we need to read integers */
+ char str[4096]; /* for special chars and font numbers */
+ char b;
+
+
+/*
+ *
+ * Controls the translation of troff's device independent output language into
+ * PostScript. The call to t_page() that prints the last page is made when we
+ * exit the loop, but probably belongs in t_trailer().
+ *
+ */
+
+
+ redirect(-1); /* only do output after a page command */
+ lineno = 1; /* line in current file */
+
+ while ((c = getc(fp)) != EOF) {
+
+ switch (c) {
+
+ case '\n': /* just count this line */
+ lineno++;
+ break;
+
+ case ' ': /* when input is text */
+ case 0: /* occasional noise creeps in */
+ break;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ /* two motion digits plus a character */
+ hmot((c-'0')*10 + getc(fp)-'0');
+ put1(getc(fp));
+ break;
+
+ case 'c': /* single ascii character */
+ put1(getc(fp));
+ break;
+
+ case 'C': /* special character */
+ sget(str, sizeof str, fp);
+ put1s(str);
+ break;
+
+ case 'N': /* character at position n */
+ fscanf(fp, "%d", &m);
+ endtext();
+ oput(m);
+ endtext();
+ break;
+
+ case 'D': /* drawing functions */
+ endtext();
+ getdraw();
+ if ( size != lastsize || (size == FRACTSIZE &&
+ fractsize != lastfractsize) ||
+ horscale != lasthorscale) {
+ subfont = 0;
+ t_sf(0);
+ }
+ switch ((c=getc(fp))) {
+ case 'p': /* draw a path */
+ while (fscanf(fp, "%d %d", &n, &m) == 2)
+ drawline(n, m);
+ lineno++;
+ break;
+
+ case 'P': /* solid polygon */
+ fprintf(tf, "newpath %d %d neg moveto\n", hpos,
+ vpos);
+ while (fscanf(fp, "%d %d", &n, &m) == 2) {
+ hpos += n;
+ vpos += m;
+ fprintf(tf, "%d %d neg lineto\n", hpos, vpos);
+ }
+ fprintf(tf, "closepath fill\n");
+ lineno++;
+ break;
+
+ case 'l': /* draw a line */
+ fscanf(fp, "%d %d %c", &n, &m, &b);
+ n1 = b;
+ drawline(n, m);
+ break;
+
+ case 'c': /* circle */
+ case 'C': /* filled circle */
+ fscanf(fp, "%d", &n);
+ drawcirc(n, c);
+ break;
+
+ case 'e': /* ellipse */
+ case 'E': /* filled ellipse */
+ fscanf(fp, "%d %d", &m, &n);
+ drawellip(m, n, c);
+ break;
+
+ case 'a': /* counter-clockwise arc */
+ case 'A': /* clockwise arc */
+ fscanf(fp, "%d %d %d %d", &n, &m, &n1, &m1);
+ drawarc(n, m, n1, m1, c);
+ break;
+
+ case 'q': /* spline without end points */
+ drawspline(fp, 1);
+ lineno++;
+ break;
+
+ case '~': /* wiggly line */
+ drawspline(fp, 2);
+ lineno++;
+ break;
+
+ case 't': /* set line width, ignore */
+ fscanf(fp, "%d %d", &m, &n);
+ hgoto(hpos + m);
+ lineno++;
+ break;
+
+ case 'F': /* color scheme, ignore */
+ case 'f': /* filling color, ignore */
+ fgets(str, sizeof str, fp);
+ lineno++;
+ break;
+
+ default:
+ error(FATAL, "unknown drawing function %c", c);
+ break;
+ } /* End switch */
+ break;
+
+ case 's': /* use this point size */
+ fscanf(fp, "%d", &n); /* ignore fractional sizes */
+ if (n != FRACTSIZE)
+ setsize(t_size(n), 0);
+ else {
+ float f;
+ fscanf(fp, "%f", &f);
+ setsize(FRACTSIZE, f);
+ }
+ break;
+
+ case 'f': /* use font mounted here */
+ sget(str, sizeof str, fp);
+ setfont(t_font(str));
+ break;
+
+ case 'H': /* absolute horizontal motion */
+ fscanf(fp, "%d", &n);
+ hgoto(n);
+ break;
+
+ case 'h': /* relative horizontal motion */
+ fscanf(fp, "%d", &n);
+ hmot(n);
+ break;
+
+ case 'w': /* word space */
+ wordspace++;
+ break;
+
+ case 'V': /* absolute vertical position */
+ fscanf(fp, "%d", &n);
+ vgoto(n);
+ break;
+
+ case 'v': /* relative vertical motion */
+ fscanf(fp, "%d", &n);
+ vmot(n);
+ break;
+
+ case 'p': /* new page */
+ fscanf(fp, "%d", &n);
+ t_page(n);
+ break;
+
+ case 'n': /* end of line */
+ while ( (c = getc(fp)) != '\n' && c != EOF ) ;
+ t_newline();
+ lineno++;
+ break;
+
+ case '#': /* comment */
+ while ( (c = getc(fp)) != '\n' && c != EOF ) ;
+ lineno++;
+ break;
+
+ case 'x': /* device control function */
+ devcntrl(fp);
+ lineno++;
+ break;
+
+ default:
+ error(FATAL, "unknown input character %o %c", c, c);
+ done();
+
+ } /* End switch */
+
+ } /* End while */
+
+ t_page(-1); /* print the last page */
+ endtext();
+
+} /* End of conv */
+
+
+/*****************************************************************************/
+
+void
+devcntrl(
+
+
+ FILE *fp /* current input file */
+)
+
+
+{
+
+
+ char str[4096], *buf, str1[4096];
+ int c, n, size;
+
+
+/*
+ *
+ * Called from conv() to process the rest of a device control function. There's
+ * a whole family of them and they all start with the string "x ", which we've
+ * already read. The "x X ..." commands are an extensible (and device dependent)
+ * family that we use here for things like picture inclusion. Unrecognized device
+ * control commands are ignored.
+ *
+ */
+
+
+ buf = malloc(size = 4096);
+ sget(str, sizeof str, fp); /* get the control function name */
+
+ switch ( str[0] ) { /* only the first character counts */
+
+ case 'i': /* initialize */
+ t_init();
+ break;
+
+ case 'T': /* device name */
+ sget(devname, sizeof devname, fp);
+ getdevmap();
+ /*
+ * This used to be "strcpy(devname, realdev);" but
+ * it does not work when DESC is a text file because
+ * the fonts are in a different directory.
+ */
+ if (dev.afmfonts || (devname[0] == 'p' && devname[1] == 's'))
+ realdev = devname;
+ else
+ n_strcpy(devname, realdev, sizeof(devname));
+ break;
+
+ case 't': /* trailer */
+ t_trailer();
+ break;
+
+ case 'p': /* pause -- can restart */
+ t_reset('p');
+ break;
+
+ case 's': /* stop */
+ t_reset('s');
+ break;
+
+ case 'r': /* resolution assumed when prepared */
+ fscanf(fp, "%d", &res);
+ break;
+
+ case 'f': /* load font in a position */
+ fscanf(fp, "%d", &n);
+ sget(str, sizeof str, fp);
+ fgets(buf, size, fp); /* in case there's a filename */
+ ungetc('\n', fp); /* fgets() goes too far */
+ str1[0] = '\0'; /* in case there's nothing to come in */
+ c = 0;
+ sscanf(buf, "%s %d", str1, &c);
+ loadfont(n, mapdevfont(str), str1, 0, c);
+ break;
+
+ /* these don't belong here... */
+ case 'H': /* char height */
+ fscanf(fp, "%d", &n);
+ if (n != FRACTSIZE)
+ t_charht(n, 0);
+ else {
+ float f;
+ fscanf(fp, "%f", &f);
+ t_charht(FRACTSIZE, f);
+ }
+ break;
+
+ case 'S': /* slant */
+ fscanf(fp, "%d", &n);
+ t_slant(n);
+ break;
+
+ case 'X': /* copy through - from troff */
+ do
+ c = getc(fp);
+ while (spacechar(c));
+ n = 0;
+ if (c != EOF) do {
+ if (n + 1 < sizeof str)
+ str[n++] = c;
+ c = getc(fp);
+ } while (c != EOF && !spacechar(c) && c != ':');
+ str[n] = 0;
+ if (c != ':')
+ ungetc(c, fp);
+ n = 0;
+ for (;;) {
+ fgets(&buf[n], size - n, fp);
+ if ((c = getc(fp)) != '+') {
+ ungetc(c, fp);
+ break;
+ }
+ while (buf[n])
+ n++;
+ if (size - n < 4096)
+ buf = realloc(buf, size += 4096);
+ lineno++;
+ }
+ if ( strcmp(str, "PI") == 0 || strcmp(str, "PictureInclusion") == 0 )
+ picture(buf);
+ else if ( strcmp(str, "InlinePicture") == 0 )
+ inlinepic(fp, buf);
+ else if ( strcmp(str, "SupplyFont") == 0 )
+ t_supply(buf);
+ else if ( strcmp(str, "PaperSize") == 0 )
+ t_papersize(buf);
+ else if ( strcmp(str, "TrimAt") == 0 )
+ t_cutat("Trim size", &trimat, buf);
+ else if ( strcmp(str, "BleedAt") == 0 )
+ t_cutat("Bleed size", &bleedat, buf);
+ else if ( strcmp(str, "CropAt") == 0 )
+ t_cutat("Crop size", &cropat, buf);
+ else if ( strcmp(str, "Track") == 0 )
+ t_track(buf);
+ else if ( strcmp(str, "PDFMark") == 0 )
+ t_pdfmark(buf);
+ else if ( strcmp(str, "LC_CTYPE") == 0 )
+ t_locale(buf);
+ else if ( strcmp(str, "Anchor") == 0 )
+ t_anchor(buf);
+ else if ( strcmp(str, "Link") == 0 )
+ t_link(buf);
+ else if ( strcmp(str, "SetLinkColor") == 0 )
+ t_linkcolor(buf);
+ else if ( strcmp(str, "SetLinkBorder") == 0 )
+ t_linkborder(buf);
+ else if ( strcmp(str, "SetBorderStyle") == 0 )
+ linkborderstyle = t_linkborderstyle(buf);
+ else if ( strcmp(str, "SetUBorderStyle") == 0 )
+ ulinkborderstyle = t_linkborderstyle(buf);
+ else if ( strcmp(str, "ULink") == 0 )
+ t_ulink(buf);
+ else if ( strcmp(str, "SetULinkColor") == 0 )
+ t_ulinkcolor(buf);
+ else if ( strcmp(str, "SetULinkBorder") == 0 )
+ t_ulinkborder(buf);
+ else if ( strcmp(str, "HorScale") == 0 )
+ sethorscale(buf);
+ else if ( strcmp(str, "BeginPath") == 0 )
+ beginpath(buf, FALSE);
+ else if ( strcmp(str, "DrawPath") == 0 )
+ drawpath(buf, FALSE);
+ else if ( strcmp(str, "BeginObject") == 0 )
+ beginpath(buf, TRUE);
+ else if ( strcmp(str, "EndObject") == 0 )
+ drawpath(buf, TRUE);
+ else if ( strcmp(str, "NewBaseline") == 0 )
+ newbaseline(buf);
+ else if ( strcmp(str, "DrawText") == 0 )
+ drawtext(buf);
+ else if ( strcmp(str, "SetText") == 0 )
+ settext(buf);
+ else if ( strcmp(str, "SetColor") == 0 ) {
+ newcolor(buf);
+ setcolor();
+ } else if ( strcmp(str, "Sync") == 0 ) {
+ if (tracked)
+ tracked = -1;
+ subfont = 0;
+ t_sf(1);
+ xymove(hpos, vpos);
+ } else if ( strcmp(str, "PSSetup") == 0 ) {
+ fprintf(gf, "%s", buf);
+ } else if ( strcmp(str, "PS") == 0 || strcmp(str, "PostScript") == 0 ) {
+ endtext();
+ /* xymove(hpos, vpos); ul90-22006 */
+ fprintf(tf, "%s", buf);
+ } /* End else */
+ goto done;
+ } /* End switch */
+
+ while ( (c = getc(fp)) != '\n' && c != EOF ) ;
+done:
+ free(buf);
+
+} /* End of devcntrl */
+
+
+/*****************************************************************************/
+
+
+void
+fontinit(void)
+
+
+{
+
+
+ char *descp; /* for reading the DESC file */
+ char *filebase; /* the whole thing goes here */
+ int i; /* loop index */
+
+
+/*
+ *
+ * Reads *realdev's DESC file and uses what's there to initialize things like
+ * the list of available point sizes. Old versions of the program used *devname's
+ * DESC file to initialize nfonts, but that meant we needed to have *devname's
+ * binary font files available for emulation. That restriction has been removed
+ * and we now set nfonts using the "x font" commands in the input file, so by the
+ * time we get here all we really need is *realdev. In fact devcntrl() reads the
+ * device name from the "x T ..." command, but almost immediately replaces it with
+ * string *realdev so we end up using *realdev's DESC file. Later on (in
+ * t_font()) we mount all of *realdev's special fonts after the last legitimate
+ * font position, just to be sure device emulation works reasonably well - there's
+ * no guarantee *devname's special fonts match what's needed when *realdev's tables
+ * are used.
+ *
+ */
+
+
+ snprintf(temp, sizeof temp, "%s/dev%s/FONTMAP", fontdir, devname);
+ rdftmap(temp);
+ snprintf(temp, sizeof temp, "%s/dev%s/DESC", fontdir, devname);
+ if ( (descp = readdesc(temp)) == 0 )
+ error(FATAL, "can't open tables for %s", temp);
+
+ memcpy(&dev, descp, sizeof dev);
+
+ nfonts = 0; /* was dev.nfonts - now set in t_fp() */
+ nsizes = dev.nsizes;
+ nchtab = dev.nchtab;
+ unitwidth = dev.unitwidth;
+
+ filebase = &descp[sizeof dev];
+
+ pstab = (int *) filebase;
+ chtab = (short *)(pstab + nsizes + 1);
+ chname = (char *) (chtab + nchtab);
+ fsize = 3 * 255 + nchtab + 128 - 32 + sizeof(struct Font);
+
+ fitab = calloc(NFONT+1, sizeof *fitab);
+ fontab = calloc(NFONT+1, sizeof *fontab);
+ codetab = calloc(NFONT+1, sizeof *codetab);
+ kerntab = calloc(NFONT+1, sizeof *kerntab);
+ fontbase = calloc(NFONT+1, sizeof *fontbase);
+
+ for ( i = 1; i <= NFONT; i++ ) { /* so loadfont() knows nothing's there */
+ fontbase[i] = NULL;
+ } /* End for */
+
+ if ( (downloaded = (char *) calloc(nchtab + 128, sizeof(char))) == NULL )
+ error(FATAL, "no memory");
+
+} /* End of fontinit */
+
+
+/*****************************************************************************/
+
+
+void
+loadfont (
+ int n, /* load this font position */
+ char *s, /* with the file for this font */
+ char *s1, /* taken from here - possibly */
+ int forcespecial, /* this is definitively a special font */
+ int spec /* map specification */
+)
+
+
+{
+
+
+ char *fpout = NULL; /* for reading *s file */
+ int fin; /* for reading *s.afm file */
+ int nw; /* number of width table entries */
+ char *p;
+ char *path;
+ size_t l;
+
+
+/*
+ *
+ * Loads font position n with the binary font file for *s provided it's not
+ * already there. If *s1 is NULL or points to the empty string we read files from
+ * directory *fontdir/dev*devname, otherwise directory *s1 is used. If the first
+ * open fails we try to map font *s into one we expect will be available, and then
+ * we try again.
+ *
+ */
+
+
+ if ( n < 0 || n > NFONT ) /* make sure it's a legal position */
+ error(FATAL, "illegal fp command %d %s", n, s);
+
+ if ( fontbase[n] != NULL && strcmp(s, fontbase[n]->namefont) == 0 )
+ return;
+
+ path = temp;
+ if (s1 && strchr(s1, '/') != NULL)
+ path = afmdecodepath(s1);
+ else if (s1 && strstr(s1, ".afm") != NULL)
+ snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, s1);
+ else if (strchr(s, '/') != NULL) {
+ path = afmdecodepath(s);
+ if (spec == 0 && s1)
+ spec = atoi(s1);
+ } else if (strstr(s, ".afm") != NULL) {
+ snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, s);
+ if (spec == 0 && s1)
+ spec = atoi(s1);
+ } else snprintf(temp, sizeof temp, "%s/dev%s/%s.afm", fontdir, devname, s);
+
+ if ( (fin = open(path, O_RDONLY)) >= 0 ) {
+ struct afmtab *a;
+ struct stat st;
+ char *contents;
+ int i;
+ if ((p = strrchr(s, '/')) == NULL)
+ p = s;
+ else
+ p++;
+ if (p[0] == 'S' && (p[1] == '\0' || (digitchar(p[1]&0377) &&
+ p[2] == '\0') || p[2] == '.'))
+ forcespecial = 1;
+ for (i = 0; i < afmcount; i++)
+ if (afmfonts[i] && strcmp(afmfonts[i]->path, path) == 0 &&
+ afmfonts[i]->spec == spec) {
+ a = afmfonts[i];
+ close(fin);
+ goto have;
+ }
+ if ((a = calloc(1, sizeof *a)) == NULL ||
+ fstat(fin, &st) < 0 ||
+ (contents = malloc(st.st_size+1)) == NULL ||
+ read(fin, contents, st.st_size) != st.st_size) {
+ free(a);
+ close(fin);
+ goto fail;
+ }
+ close(fin);
+ l = strlen(path) + 1;
+ a->path = malloc(l);
+ n_strcpy(a->path, path, l);
+ if (path != temp)
+ free(path);
+ a->file = s;
+ a->spec = spec;
+ if (afmget(a, contents, st.st_size) < 0) {
+ free(a);
+ free(contents);
+ goto fail;
+ }
+ free(contents);
+ afmfonts = realloc(afmfonts, (afmcount+1) * sizeof *afmfonts);
+ afmfonts[afmcount] = a;
+ snprintf(a->Font.intname, sizeof a->Font.intname,
+ "%d", dev.nfonts + ++afmcount);
+ if (forcespecial)
+ a->Font.specfont = 1;
+have: fontbase[n] = &a->Font;
+ fontab[n] = a->fontab;
+ codetab[n] = a->codetab;
+ fitab[n] = a->fitab;
+ t_fp(n, a->fontname, fontbase[n]->intname, a);
+ goto done;
+ }
+ if (strchr(s, '/') != NULL)
+ goto fail;
+ if ( s1 == NULL || s1[0] == '\0' )
+ snprintf(temp, sizeof temp, "%s/dev%s/%s", fontdir, devname, s);
+ else snprintf(temp, sizeof temp, "%s/%s", s1, s);
+
+ if ( access(temp, R_OK) < 0 )
+ snprintf(temp, sizeof temp, "%s/dev%s/%s",
+ fontdir, devname, mapfont(s));
+ if ((fpout = readfont(temp, &dev, 0)) == NULL)
+ fail: error(FATAL, "can't open font table %s", temp);
+
+ if ( fontbase[n] != NULL ) /* something's already there */
+ free(fontbase[n]); /* so release the memory first */
+
+ fontbase[n] = (struct Font *)fpout;
+
+ p = (char *) fontbase[n] + sizeof(struct Font);
+ nw = fontbase[n]->nwfont & BMASK;
+ makefont(n, p, NULL, p + 2 * nw, p + 3 * nw, nw);
+
+ t_fp(n, fontbase[n]->namefont, fontbase[n]->intname, NULL);
+
+done:
+ if ( smnt == 0 && (fontbase[n]->specfont == 1 || forcespecial) )
+ smnt = n;
+ if (fontbase[n]->specfont == 1 || forcespecial)
+ gotregular = TRUE;
+
+ if ( debug == ON )
+ fontprint(n);
+
+} /* End of loadfont */
+
+
+/*****************************************************************************/
+
+
+void
+loadspecial(void)
+
+
+{
+
+
+ char *p; /* for next binary font file */
+ int nw; /* width entries in next font */
+ int i; /* loop index */
+
+
+/*
+ *
+ * Loads all the special fonts after the last legal font position. Mostly used
+ * for device emulation, but we'll do it no matter what. Needed because there's
+ * no consistency in special fonts across different devices, and relying on having
+ * them mounted in the input file doesn't guarantee the whole collection will be
+ * there. The special fonts are determined and mounted using the copy of the
+ * DESC file that's been read into memory. Initially had this stuff at the
+ * end of fontinit(), but we now don't know nfonts until much later.
+ *
+ */
+
+ if ( gotregular == FALSE )
+ loadfont(++nfonts, ((struct Font *)(&chname[dev.lchname]))->namefont,
+ NULL, 0, 0);
+
+ if ( gotspecial == FALSE )
+ for ( i = 1, p = chname + dev.lchname; i <= dev.nfonts; i++ ) {
+ nw = *p & BMASK;
+ if ( ((struct Font *) p)->specfont == 1 )
+ loadfont(++nfonts, ((struct Font *)p)->namefont, NULL, 1, 0);
+ p += 3 * nw + dev.nchtab + 128 - 32 + sizeof(struct Font);
+ } /* End for */
+
+ gotregular = TRUE;
+ gotspecial = TRUE;
+
+} /* End of loadspecial */
+
+
+/*****************************************************************************/
+char *defaultFonts[] =
+ { "R", "I", "B", "BI", "CW", "H", "HB", "HX", "S1", "S", NULL };
+
+void
+loaddefault(void)
+{
+ int i;
+
+ for (i = 0; defaultFonts[i] != NULL ; i++)
+ loadfont(++nfonts, defaultFonts[i], NULL, defaultFonts[i][0] == 'S', 0);
+}
+
+
+void
+fontprint (
+ int i /* font's index in fontbase[] */
+)
+
+
+{
+
+
+ int j, n;
+ char *p;
+
+
+/*
+ *
+ * Debugging routine that dumps data about the font mounted in position i.
+ *
+ */
+
+
+ fprintf(tf, "font %d:\n", i);
+
+ p = (char *) fontbase[i];
+ n = fontbase[i]->nwfont & BMASK;
+
+ fprintf(tf, "base=0%lo, nchars=%d, spec=%d, name=%s, widtab=0%lo, fitab=0%lo\n",
+ (long)p, n, fontbase[i]->specfont, fontbase[i]->namefont, (long)fontab[i], (long)fitab[i]);
+
+ fprintf(tf, "widths:\n");
+ for ( j = 0; j <= n; j++ ) {
+ fprintf(tf, " %2d", fontab[i][j]);
+ if ( j % 20 == 19 ) putc('\n', tf);
+ } /* End for */
+
+ fprintf(tf, "\ncodetab:\n");
+ for ( j = 0; j <= n; j++ ) {
+ fprintf(tf, " %2d", codetab[i][j]);
+ if ( j % 20 == 19 ) putc('\n', tf);
+ } /* End for */
+
+ fprintf(tf, "\nfitab:\n");
+ for ( j = 0; j <= dev.nchtab + 128-32; j++ ) {
+ fprintf(tf, " %2d", fitab[i][j]);
+ if ( j % 20 == 19 ) putc('\n', tf);
+ } /* End for */
+
+ putc('\n', tf);
+
+} /* End of fontprint */
+
+
+/*****************************************************************************/
+
+
+char *
+mapfont (
+ char *name /* troff wanted this font */
+)
+
+
+{
+
+
+ int i; /* loop index */
+
+
+/*
+ *
+ * If loadfont() can't find font *name we map it into something else that should
+ * be available and return a pointer to the new name. Used mostly for emulating
+ * devices like the APS-5.
+ *
+ */
+
+
+ name = mapft(name);
+ for ( i = 0; fontmap[i].name != NULL; i++ )
+ if ( strcmp(name, fontmap[i].name) == 0 )
+ return(fontmap[i].use);
+
+ switch ( *++name ) {
+ case 'I':
+ return("I");
+
+ case 'B':
+ return("B");
+
+ case 'X':
+ return("BI");
+
+ default:
+ return("R");
+ } /* End switch */
+
+} /* End of mapfont */
+
+
+/*****************************************************************************/
+
+
+void
+getdevmap(void)
+
+
+{
+
+
+ FILE *fp; /* for reading the device fontmap file */
+ int i = 0; /* number of mapping pairs we've read */
+ int c; /* for skipping lines */
+
+
+/*
+ *
+ * Looks for the device font mapping file *fontdir/dev*realdev/fontmaps/devname.
+ * The file, if it exists, should be an ASCII file containing pairs of one or two
+ * character font names per line. The first name is the font troff will be asking
+ * for and the second is the one we'll use. Comments are lines that begin with
+ * a '#' as the first non-white space character on a line. The devfontmap list
+ * ends with a member that has the empty string in the name field.
+ *
+ */
+
+
+ snprintf(temp, sizeof temp, "%s/dev%s/fontmaps/%s",
+ fontdir, realdev, devname);
+
+ if ( devfontmap == NULL && (fp = fopen(temp, "r")) != NULL ) {
+ devfontmap = (Devfontmap *) malloc(10 * sizeof(Devfontmap));
+
+ while ( sget(temp, sizeof temp, fp) == 1 ) {
+ if ( temp[0] != '#' && strlen(temp) < 3 )
+ if ( sget(&temp[3], sizeof temp - 3, fp) == 1 &&
+ strlen(&temp[3]) < 3 ) {
+ n_strcpy((devfontmap + i)->name, temp,
+ sizeof(devfontmap->name));
+ n_strcpy((devfontmap + i)->use, &temp[3],
+ sizeof(devfontmap->use));
+ if ( ++i % 10 == 0 )
+ devfontmap = (Devfontmap *) realloc(devfontmap, (i + 10) * sizeof(Devfontmap));
+ } /* End if */
+ while ( (c = getc(fp)) != '\n' && c != EOF ) ;
+ } /* End while */
+
+ (devfontmap + i)->name[0] = '\0'; /* end the list we just read */
+ fclose(fp);
+ } /* End if */
+
+} /* End of getdevmap */
+
+
+/*****************************************************************************/
+
+
+char *
+mapdevfont(char *str)
+
+
+{
+
+
+ int i;
+
+
+/*
+ *
+ * Called immediately before loadfont() after an 'x font' command is recognized.
+ * Takes the font name that troff asked for, looks it up in the devfontmap list,
+ * and returns the mapped name to the caller. No mapping is done if the devfontmap
+ * list is empty or font *str isn't found in the list.
+ *
+ */
+
+
+ if ( devfontmap != NULL )
+ for ( i = 0; (devfontmap + i)->name[0] != '\0'; i++ )
+ if ( strcmp((devfontmap + i)->name, str) == 0 )
+ return((devfontmap + i)->use);
+
+ return(str);
+
+} /* End of mapdevfont */
+
+
+/*****************************************************************************/
+
+
+void
+reset(void)
+
+
+{
+
+
+/*
+ *
+ * Resets the variables that keep track of the printer's current position, font,
+ * and size. Typically used after a restore/save pair (eg. when we finish with a
+ * page) to make sure we force the printer back into sync (in terms of the font
+ * and current point) before text is printed.
+ *
+ */
+
+
+ lastx = -(slop + 1);
+ savey = lasty = -1;
+ lastfont = lastsubfont = lastsize = -1;
+ if (tracked)
+ tracked = -1;
+
+} /* End of reset */
+
+
+/*****************************************************************************/
+
+
+void
+resetpos(void)
+
+
+{
+
+
+/*
+ *
+ * Resets the variables that keep track of the printer's current position. Used
+ * when there's a chance we've lost track of the printer's current position or
+ * done something that may have wiped it out, and we want to force dpost to set
+ * the printer's position before printing text or whatever. For example stroke or
+ * fill implicitly do a newpath, and that wipes out the current point, unless the
+ * calls were bracketed by a gsave/grestore pair.
+ *
+ */
+
+
+ lastx = -(slop + 1);
+ savey = lasty = -1;
+
+} /* End of resetpos */
+
+
+/*****************************************************************************/
+
+
+void
+t_init(void)
+
+
+{
+
+
+ static int initialized = FALSE; /* only do most things once */
+
+
+/*
+ *
+ * Called from devcntrl() after an "x init" command is read. Things only work if
+ * we've already seen the "x res" command, and much of the stuff, including the
+ * call to setup, should only be done once. Restricting everything to one call of
+ * setup (ie. the one in the prologue) means all the input files must have been
+ * formatted for the same device.
+ *
+ */
+
+
+ endtext(); /* moved - for cat'ed troff files */
+
+ if ( initialized == FALSE ) { /* only do this stuff once per job */
+ fontinit();
+ gotspecial = FALSE;
+ gotregular = FALSE;
+ widthfac = (float) res /dev.res;
+ if (dev.afmfonts) {
+ if (Sflag == 0)
+ pointslop = 0;
+ }
+ if (eflag == 0)
+ realencoding = encoding = dev.encoding;
+ if (encoding == 5) {
+ LanguageLevel = MAX(LanguageLevel, 2);
+ Binary++;
+ }
+ slop = pointslop * res / POINTS + .5;
+ rvslop = res * .025;
+ setup();
+ initialized = TRUE;
+ } /* End if */
+
+ hpos = vpos = 0; /* upper left corner */
+ setsize(t_size(10), 0); /* start somewhere */
+ reset(); /* force position and font stuff - later */
+
+} /* End of t_init */
+
+
+/*****************************************************************************/
+
+void
+needresource(const char *s, ...)
+{
+ va_list ap;
+
+ if (nfcount++ == 0)
+ fprintf(nf, "%%%%DocumentNeededResources: ");
+ else
+ fprintf(nf, "%%%%+ ");
+ va_start(ap, s);
+ vfprintf(nf, s, ap);
+ va_end(ap);
+ putc('\n', nf);
+}
+
+
+static struct supplylist {
+ struct supplylist *next;
+ char *font;
+ char *file;
+ char *type;
+ int done;
+} *supplylist;
+
+void
+t_supply(char *font) /* supply a font */
+{
+ struct supplylist *sp;
+ char *np, *file, *type = NULL, c;
+
+ while (*font == ' ' || *font == '\t')
+ font++;
+ for (np = font; *np && *np != ' ' && *np != '\t' && *np != '\n'; np++);
+ if (*np == '\0' || *np == '\n')
+ return;
+ *np = '\0';
+ file = &np[1];
+ while (*file == ' ' || *file == '\t')
+ file++;
+ for (np = file; *np && *np != ' ' && *np != '\t' && *np != '\n'; np++);
+ c = *np;
+ *np = '\0';
+ if (c != '\0' && c != '\n') {
+ type = &np[1];
+ while (*type == ' ' || *type == '\t')
+ type++;
+ for (np = type; *np && *np != ' ' &&
+ *np != '\t' && *np != '\n'; np++);
+ *np = '\0';
+ }
+ for (sp = supplylist; sp; sp = sp->next)
+ if (strcmp(sp->font, font) == 0)
+ return;
+ sp = calloc(1, sizeof *sp);
+ sp->font = strdup(font);
+ sp->file = afmdecodepath(file);
+ sp->type = type && *type ? strdup(type) : NULL;
+ sp->next = supplylist;
+ supplylist = sp;
+}
+
+static unsigned long
+ple32(const char *cp)
+{
+ return (unsigned long)(cp[0]&0377) +
+ ((unsigned long)(cp[1]&0377) << 8) +
+ ((unsigned long)(cp[2]&0377) << 16) +
+ ((unsigned long)(cp[3]&0377) << 24);
+}
+
+static const char ps_adobe_font_[] = "%!PS-AdobeFont-";
+static const char ps_truetypefont[] = "%!PS-TrueTypeFont";
+static const char hex[] = "0123456789abcdef";
+
+static void
+supplypfb(char *font, char *path, FILE *fp)
+{
+ char buf[30];
+ long length;
+ int i, c = EOF, n, type = 0, lastc = EOF;
+
+ if (fread(buf, 1, 6, fp) != 6)
+ error(FATAL, "no data in %s", path);
+ if ((buf[0]&0377) != 0200 || (type = buf[1]) != 1)
+ error(FATAL, "invalid header in %s", path);
+ length = ple32(&buf[2]);
+ n = 0;
+ while (ps_adobe_font_[n] && --length > 0 && (c = getc(fp)) != EOF) {
+ if (c != ps_adobe_font_[n++])
+ error(FATAL, "file %s does not start with \"%s\"",
+ path, ps_adobe_font_);
+ }
+ while (--length > 0 && (c = getc(fp)) != EOF && c != '\r' && c != '\n');
+ if (c != '\n') {
+ if ((c = getc(fp)) != '\n')
+ ungetc(c, fp);
+ else
+ length--;
+ }
+ if (sfcount++ == 0)
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ else
+ fprintf(sf, "%%%%+ font %s\n", font);
+ fprintf(rf, "%%%%BeginResource: font %s\n", font);
+ for (;;) {
+ switch (type) {
+ case 1:
+ while (length > 0 && (c = getc(fp)) != EOF) {
+ length--;
+ switch (c) {
+ case '\r':
+ if ((c = getc(fp)) != '\n')
+ ungetc(c, fp);
+ else
+ length--;
+ putc('\n', rf);
+ lastc = '\n';
+ break;
+ case 0:
+ continue;
+ default:
+ putc(c, rf);
+ lastc = c;
+ }
+ }
+ if (c == EOF)
+ error(FATAL, "short text data in %s", path);
+ break;
+ case 2:
+ while (length) {
+ n = length > sizeof buf ? sizeof buf : length;
+ if (fread(buf, 1, n, fp) != n)
+ error(FATAL, "short binary data in %s", path);
+ for (i = 0; i < n; i++) {
+ putc(hex[(buf[i]&0360)>>4], rf);
+ putc(hex[buf[i]&017], rf);
+ }
+ putc('\n', rf);
+ lastc = '\n';
+ length -= n;
+ }
+ break;
+ case 3:
+ if (lastc != '\n')
+ putc('\n', rf);
+ fprintf(rf, "%%%%EndResource\n");
+ fclose(fp);
+ return;
+ default:
+ error(FATAL, "invalid header type %d in %s", path, type);
+ }
+ if ((n = fread(buf, 1, 6, fp)) != 6 && (buf[1] != 3 || n < 2))
+ error(FATAL, "missing header in %s", path);
+ if ((buf[0]&0377) != 0200)
+ error(FATAL, "invalid header in %s", path);
+ if ((type = buf[1]) != 3)
+ length = ple32(&buf[2]);
+ }
+}
+
+static void
+supplyotf(char *font, char *path, FILE *fp)
+{
+ static int cffcount;
+ struct stat st;
+ char *contents;
+ size_t size, offset, length;
+ int i;
+ int fsType;
+ const char StartData[] = " StartData ";
+
+ if (fstat(fileno(fp), &st) < 0)
+ error(FATAL, "cannot stat %s", path);
+ size = st.st_size;
+ contents = malloc(size);
+ if (fread(contents, 1, size, fp) != size)
+ error(FATAL, "cannot read %s", path);
+ fclose(fp);
+ if ((fsType = otfcff(path, contents, size, &offset, &length)) < 0) {
+ free(contents);
+ return;
+ }
+ /*
+ * Adobe Technical Note #5176, "The Compact Font Format
+ * Specification", Version 1.0, 12/4/2003, p. 53 proposes
+ * a weird syntax for CFF DSC comments ("ProcSet" etc.);
+ * Adobe Distiller 7 complains about it with DSC warnings
+ * enabled. What follows is an attempt to fix this.
+ */
+ if (cffcount++ == 0) {
+ fprintf(rf, "%%%%IncludeResource: procset FontSetInit 0 0\n");
+ needresource("procset FontSetInit 0 0");
+ }
+ if (sfcount++ == 0)
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ else
+ fprintf(sf, "%%%%+ font %s\n", font);
+ fprintf(rf, "%%%%BeginResource: font %s\n", font);
+ fprintf(rf, "/FontSetInit /ProcSet findresource begin\n");
+ if (encoding == 5) {
+ fprintf(rf, "%%%%BeginData: %ld Binary Bytes\n",
+ (long)(length + 13 + strlen(font) + 12));
+ fprintf(rf, "/%s %12ld StartData ", font, (long)length);
+ fwrite(&contents[offset], 1, length, rf);
+ fprintf(rf, "\n%%%%EndData\n");
+ } else {
+ fprintf(rf, "/%s %ld ", font, (long)length);
+ fprintf(rf, "currentfile /ASCIIHexDecode filter cvx exec\n");
+ for (i = 0; StartData[i]; i++) {
+ putc(hex[(StartData[i]&0360)>>4], rf);
+ putc(hex[StartData[i]&017], rf);
+ }
+ putc('\n', rf);
+ for (i = offset; i < offset+length; i++) {
+ putc(hex[(contents[i]&0360)>>4], rf);
+ putc(hex[contents[i]&017], rf);
+ if (i > offset && (i - offset + 1) % 34 == 0)
+ putc('\n', rf);
+ }
+ fprintf(rf, ">\n");
+ }
+ fprintf(rf, "%%%%EndResource\n");
+ free(contents);
+ LanguageLevel = MAX(LanguageLevel, 3);
+}
+
+static void
+supplyttf(char *font, char *path, FILE *fp)
+{
+ struct stat st;
+ char *contents;
+ size_t size;
+
+ if (fstat(fileno(fp), &st) < 0)
+ error(FATAL, "cannot stat %s", path);
+ size = st.st_size;
+ contents = malloc(size);
+ if (fread(contents, 1, size, fp) != size)
+ error(FATAL, "cannot read %s", path);
+ fclose(fp);
+ if (sfcount++ == 0)
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ else
+ fprintf(sf, "%%%%+ font %s\n", font);
+ fprintf(rf, "%%%%BeginResource: font %s\n", font);
+ otft42(font, path, contents, size, rf);
+ fprintf(rf, "%%%%EndResource\n");
+ free(contents);
+ LanguageLevel = MAX(LanguageLevel, 2);
+}
+
+static void
+supply1(char *font, char *file, char *type)
+{
+ FILE *fp;
+ char line[4096], c;
+
+ if (strchr(file, '/') == 0) {
+ snprintf(temp, sizeof temp, "%s/dev%s/%s.%s",
+ fontdir, devname, file, type);
+ file = temp;
+ }
+ if ((fp = fopen(file, "r")) == NULL)
+ error(FATAL, "can't open %s", file);
+ if (type == NULL) {
+ c = getc(fp);
+ ungetc(c, fp);
+ type = c == '\200' ? "pfb" : c == 'O' ? "otf" :
+ c == 0 || c == 't' ? "ttf" : "anything";
+ }
+ if (strcmp(type, "pfb") == 0) {
+ supplypfb(font, file, fp);
+ return;
+ }
+ if (strcmp(type, "otf") == 0) {
+ supplyotf(font, file, fp);
+ return;
+ }
+ if (strcmp(type, "ttf") == 0) {
+ supplyttf(font, file, fp);
+ return;
+ }
+ if (fgets(line, sizeof line, fp) == NULL)
+ error(FATAL, "missing data in %s", file);
+ if (strncmp(line, ps_adobe_font_, strlen(ps_adobe_font_)) &&
+ strncmp(line, ps_truetypefont, strlen(ps_truetypefont)))
+ error(FATAL, "file %s does not start with \"%s\" or \"%s\"",
+ file, ps_adobe_font_, ps_truetypefont);
+ if (sfcount++ == 0)
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ else
+ fprintf(sf, "%%%%+ font %s\n", font);
+ fprintf(rf, "%%%%BeginResource: font %s\n", font);
+ while (fgets(line, sizeof line, fp) != NULL)
+ fputs(line, rf);
+ fclose(fp);
+ fprintf(rf, "%%%%EndResource\n");
+}
+
+static void
+t_dosupply(const char *font)
+{
+ struct supplylist *sp;
+
+ for (sp = supplylist; sp; sp = sp->next)
+ if (strcmp(sp->font, font) == 0) {
+ if (sp->done == 0) {
+ supply1(sp->font, sp->file, sp->type);
+ sp->done = 1;
+ }
+ return;
+ }
+ needresource("font %s", font);
+}
+
+/*****************************************************************************/
+
+static void
+boxcmp(const char *name, struct box *bp, int a, int b, int c, int d)
+{
+ if (bp->flag && (a != bp->val[0] || b != bp->val[1] ||
+ c != bp->val[2] || d != bp->val[3]))
+ error(NON_FATAL, "%s has changed, using new values", name);
+}
+
+static void
+t_papersize(char *buf)
+{
+ int x, y, setmedia = 0;
+
+ if (sscanf(buf, "%d %d %d", &x, &y, &setmedia) < 2)
+ return;
+ boxcmp("Media size", &mediasize, 0, 0, x, y);
+ mediasize.val[2] = x;
+ mediasize.val[3] = y;
+ mediasize.flag |= 1;
+ if (setmedia)
+ mediasize.flag |= 2;
+ pagelength = y * 72.0 / res;
+}
+
+static void
+t_cutat(const char *name, struct box *bp, char *buf)
+{
+ int c[4], i;
+
+ if (sscanf(buf, "%d %d %d %d", &c[0], &c[1], &c[2], &c[3]) < 4)
+ return;
+ boxcmp(name, bp, c[0], c[1], c[2], c[3]);
+ for (i = 0; i < 4; i++)
+ bp->val[i] = c[i];
+ bp->flag |= 1;
+}
+
+/*****************************************************************************/
+void
+t_page (
+ int pg /* troff's current page number */
+)
+
+
+{
+
+
+ static int lastpg = 0; /* last one we started - for ENDPAGE */
+
+
+/*
+ *
+ * Called whenever we've finished the last page and want to get ready for the
+ * next one. Also used at the end of each input file, so we have to be careful
+ * about what's done. The first time through (up to the redirect(pg) call) output
+ * goes to /dev/null because of the redirect(-1) call made in conv().
+ *
+ * Adobe now recommends that the showpage operator occur after the page level
+ * restore so it can be easily redefined to have side-effects in the printer's VM.
+ * Although it seems reasonable I haven't implemented it, because it makes other
+ * things, like selectively setting manual feed or choosing an alternate paper
+ * tray, clumsy - at least on a per page basis.
+ *
+ */
+
+
+ if ( tf == stdout ) /* count the last page */
+ printed++;
+
+ endtext(); /* print the last line? */
+
+ fprintf(tf, "_marks\n");
+ fprintf(tf, "cleartomark\n");
+ fprintf(tf, "showpage\n");
+ fprintf(tf, "restore\n");
+ fprintf(tf, "%s %d %d\n", ENDPAGE, lastpg, printed);
+
+ redirect(pg);
+
+ fprintf(tf, "%s %d %d\n", PAGE, pg, printed+1);
+ fprintf(tf, "save\n");
+ fprintf(tf, "mark\n");
+ writerequest(printed+1, tf);
+ fprintf(tf, "%d pagesetup\n", printed+1);
+ setcolor();
+
+ lastpg = pg; /* for the next ENDPAGE comment */
+ hpos = vpos = 0; /* get ready for the next page */
+ reset(); /* force position and font stuff - later */
+
+ seenpage = TRUE;
+
+} /* End of t_page */
+
+
+/*****************************************************************************/
+
+
+void
+t_newline(void)
+
+
+{
+
+
+/*
+ *
+ * Just finished the last line. All we do is set the horizontal position to 0,
+ * although even that probably isn't necessary.
+ *
+ */
+
+
+ hpos = 0;
+
+} /* End of t_newline */
+
+
+/*****************************************************************************/
+
+
+int
+t_size (
+ int n /* convert this to an internal size */
+)
+
+
+{
+
+
+ int i; /* loop index */
+
+
+/*
+ *
+ * Converts a point size into an internal size that can be used as an index into
+ * pstab[]. The internal size is one plus the index of the least upper bound of
+ * n in pstab[], or nsizes if n is larger than all the listed sizes.
+ *
+ */
+
+
+ if ( n <= pstab[0] )
+ return(1);
+ else if (n >= pstab[nsizes-1])
+ return(nsizes);
+
+ for ( i = 0; n > pstab[i]; i++ ) ;
+
+ return(i+1);
+
+} /* End of t_size */
+
+
+/*****************************************************************************/
+
+
+void
+setsize (
+ int n, float f /* new internal size */
+)
+
+
+{
+
+
+/*
+ *
+ * Now using internal size n, where pstab[n-1] is the best available approximation
+ * to the size troff asked for.
+ *
+ */
+
+
+ size = n;
+ fractsize = f;
+ lasthorscale = horscale = 1.0;
+
+} /* End of setsize */
+
+
+/*****************************************************************************/
+
+
+void
+t_fp (
+ int n, /* this position */
+ char *s, /* now has this font mounted */
+ char *si, /* its internal number */
+ void *a
+)
+
+
+{
+
+
+/*
+ *
+ * Updates nfonts and the array that keeps track of the mounted fonts. Called from
+ * loadfont() after an "x font pos font" command is read, and if pos is larger than
+ * the current value assigned to nfonts we set gotspecial to FALSE to make sure
+ * t_font() loads all the special fonts after the last legitimate font position.
+ *
+ */
+
+
+ fontname[n].name = s;
+ fontname[n].number = atoi(si);
+ fontname[n].afm = a;
+
+ if ( n == lastfont ) /* force a call to t_sf() */
+ lastfont = lastsubfont = -1;
+
+ if ( n > nfonts ) { /* got more positions */
+ nfonts = n;
+ gotspecial = FALSE;
+ gotregular = FALSE;
+ } /* End if */
+
+} /* End of t_fp */
+
+
+/*****************************************************************************/
+
+
+int
+t_font (
+ char *s /* use font in this position next */
+)
+
+
+{
+
+
+ int n;
+
+
+/*
+ *
+ * Converts the string *s into an integer and checks to make sure it's a legal
+ * font position. Also arranges to mount all the special fonts after the last
+ * legitimate font (by calling loadspecial()), provided it hasn't already been
+ * done.
+ *
+ */
+
+
+ n = atoi(s);
+
+ if ( seenpage == TRUE ) {
+ if ( n < 0 || n > nfonts )
+ error(FATAL, "illegal font position %d", n);
+
+ if ( gotspecial == FALSE || gotregular == FALSE )
+ loadspecial();
+ } /* End if */
+
+ if (tracked)
+ tracked = -1;
+ track = 0;
+
+ return(n);
+
+} /* End of t_font */
+
+/*****************************************************************************/
+static void
+sethorscale(char *buf)
+{
+ horscale = atof(buf);
+}
+
+/*****************************************************************************/
+static void
+t_track(char *buf)
+{
+ int t;
+
+/*
+ * Handling of track kerning. troff provides this parameter as a hint
+ * only. dpost can use it in combination with the PostScript "ashow"
+ * operator. When the variable "track" is not zero, the printer is
+ * advised to perform tracking by the given amount. This relieves us
+ * of the need to adjust the character position explicitly after each
+ * character and thus greatly reduces the size of the output.
+ *
+ * Currently this is done in encodings 0, 4, and 5 only.
+ */
+
+ if (sscanf(buf, "%d", &t) != 1)
+ t = 0;
+ if (t != lasttrack) {
+ tracked = -1;
+ } else if (t && tracked != -1)
+ tracked = 1;
+ track = t;
+}
+
+static void
+t_strack(void)
+{
+ endtext();
+ fprintf(tf, "%d T\n", track);
+ if (tf == stdout) {
+ tracked = track != 0;
+ lasttrack = track;
+ }
+}
+
+/*****************************************************************************/
+
+
+void
+setfont (
+ int n /* use the font mounted here */
+)
+
+
+{
+
+
+/*
+ *
+ * troff wants to use the font that's been mounted in position n. All we do here
+ * is update the variable that keeps track of the current position. PostScript
+ * font changes are handled in t_sf(), and are only generated right before we're
+ * ready to print or draw something.
+ *
+ */
+
+
+ if ( n < 0 || n > NFONT )
+ error(FATAL, "illegal font %d", n);
+ if ( fontname[n].name == NULL && fontname[n].number == 0)
+ loaddefault();
+ if ( fontname[n].name == NULL && fontname[n].number == 0)
+ error(FATAL,
+ "font %d not loaded: check 'dpost' input for 'x font %d XXX' before 'f%d'",
+ n, n, n);
+
+ font = n;
+ subfont = 0;
+ lasthorscale = horscale = 1.0;
+
+} /* End of setfont */
+
+
+/*****************************************************************************/
+static void
+endvec(struct afmtab *a, int n)
+{
+ fprintf(gf, "] def\n");
+ fprintf(gf, "\
+/%s findfont\n\
+dup length dict begin\n\
+ {1 index /FID ne {def} {pop pop} ifelse} forall\n\
+ /Encoding Encoding-@%s@%d def\n\
+ currentdict\n\
+end\n",
+ a->fontname, a->Font.intname, n);
+ if (a->spec & SPEC_S) {
+ fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " exch definefont pop\n");
+ fprintf(gf, "_Sdefsadj\n");
+ fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " /%s-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " Sdefs cf\n");
+ fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " undefinefont\n");
+ } else if (a->spec & SPEC_S1) {
+ fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " exch definefont pop\n");
+ fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " /%s-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " S1defs cf\n");
+ fprintf(gf, "/%s-tmp-@%s", a->fontname, a->Font.intname);
+ if (n) fprintf(gf, "@%d", n);
+ fprintf(gf, " undefinefont\n");
+ } else if (n)
+ fprintf(gf, "/%s-@%s@%d exch definefont pop\n",
+ a->fontname, a->Font.intname, n);
+ else
+ fprintf(gf, "/%s-@%s exch definefont pop\n",
+ a->fontname, a->Font.intname);
+ fprintf(gf, "/@%s", a->Font.intname);
+ if (n)
+ fprintf(gf, "@%d", n);
+ fprintf(gf, " /%s-@%s", a->fontname, a->Font.intname);
+ if (n)
+ fprintf(gf, "@%d", n);
+ fprintf(gf, " def\n");
+ fprintf(gf, "/&%s", a->Font.intname);
+ if (n)
+ fprintf(gf, "@%d", n);
+ fprintf(gf, " {@%s", a->Font.intname);
+ if (n)
+ fprintf(gf, "@%d", n);
+ fprintf(gf, " F} bind def\n");
+}
+
+static void
+printencsep(int *colp)
+{
+ if (*colp >= 60) {
+ putc('\n', gf);
+ *colp = 0;
+ } else {
+ putc(' ', gf);
+ (*colp)++;
+ }
+}
+
+static int *
+printencvector(struct afmtab *a)
+{
+ int i, j, k, n, col = 0, s;
+ int *encmap = NULL;
+
+ fprintf(gf, "/Encoding-@%s@0 [\n", a->Font.intname);
+ col = 0;
+ /*
+ * First, write excess entries into the positions from 1 to 31
+ * for later squeezing of characters >= 0400.
+ */
+ s = 128 - 32;
+ encmap = calloc(256 + nchtab + a->nchars, sizeof *encmap);
+ col += fprintf(gf, "/.notdef");
+ printencsep(&col);
+ for (j = 1; j < 32; j++) {
+ while (s < a->nchars + 128 - 32 + nchtab &&
+ ((k = a->fitab[s]) == 0 ||
+ a->nametab[k] == NULL))
+ s++;
+ if (s < a->nchars + 128 - 32 + nchtab &&
+ (k = a->fitab[s]) != 0 &&
+ k < a->nchars &&
+ a->nametab[k] != NULL) {
+ encmap[s - 128 + 32] = j;
+ col += fprintenc(gf, a->nametab[k]);
+ printencsep(&col);
+ s++;
+ } else {
+ col += fprintf(gf, "/.notdef");
+ printencsep(&col);
+ }
+ }
+ col += fprintf(gf, "/space");
+ printencsep(&col);
+ for (i = 1; i < a->nchars + 128 - 32 + nchtab && i < 256 - 32; i++) {
+ if (i < 128 - 32 && (k = a->fitab[i]) != 0 && k < a->nchars &&
+ a->nametab[k] != NULL) {
+ col += fprintenc(gf, a->nametab[k]);
+ printencsep(&col);
+ } else {
+ while (s < a->nchars + 128 - 32 + nchtab &&
+ ((k = a->fitab[s]) == 0 ||
+ a->nametab[k] == NULL))
+ s++;
+ if (s < a->nchars + 128 - 32 + nchtab &&
+ (k = a->fitab[s]) != 0 &&
+ k < a->nchars &&
+ a->nametab[k] != NULL) {
+ encmap[s - 128 + 32] = i + 32;
+ col += fprintenc(gf, a->nametab[k]);
+ printencsep(&col);
+ s++;
+ } else {
+ col += fprintf(gf, "/.notdef");
+ printencsep(&col);
+ }
+ }
+ }
+ endvec(a, 0);
+ n = 1;
+ while (s < a->nchars + 128 - 32 + nchtab) {
+ fprintf(gf, "/Encoding-@%s@%d [\n", a->Font.intname, n);
+ col = 0;
+ for (i = 0; i < 256; i++) {
+ while (s < a->nchars + 128 - 32 + nchtab &&
+ ((k = a->fitab[s]) == 0 ||
+ a->nametab[k] == NULL))
+ s++;
+ if (s < a->nchars + 128 - 32 + nchtab &&
+ (k = a->fitab[s]) != 0 &&
+ k < a->nchars &&
+ a->nametab[k] != NULL) {
+ encmap[s - 128 + 32] = i | n << 8;
+ col += fprintenc(gf, a->nametab[k]);
+ printencsep(&col);
+ s++;
+ } else {
+ col += fprintf(gf, "/.notdef");
+ printencsep(&col);
+ }
+ }
+ endvec(a, n++);
+ }
+ return encmap;
+}
+/*****************************************************************************/
+
+
+void
+t_sf(int forceflush)
+
+
+{
+
+
+ int fnum; /* internal font number */
+ int cmd; /* command to execute */
+
+
+/*
+ *
+ * Called whenever we need to use a new font or size. Only done right before we
+ * print a character. The seenfonts[] array keeps track of the fonts we've used.
+ * Helps manage host resident fonts and the DOCUMENTFONTS comment that's put out
+ * at the end of the job. The array is indexed by internal number. Only works for
+ * fonts that have internal numbers less than or equal to MAXINTERNAL.
+ *
+ */
+
+
+ if ( fontname[font].name == NULL )
+ return;
+
+ endtext();
+
+ if ( (fnum = fontname[font].number) > MAXINTERNAL || fnum < 0 )
+ fnum = 0;
+
+ if ( fnum > 0 && seenfonts[fnum] == 0 && hostfontdir != NULL ) {
+ snprintf(temp, sizeof temp, "%s/%s", hostfontdir, fontname[font].name);
+ if ( access(temp, 04) == 0 )
+ doglobal(temp);
+ } /* End if */
+
+ cmd = 'f';
+ if (forceflush == 0) {
+ if (font == lastfont && subfont == lastsubfont)
+ cmd = 's';
+ else if (size == lastsize && fractsize == lastfractsize)
+ cmd = 'F';
+ }
+ if (horscale != 1.0)
+ cmd = 'h';
+ if ( tf == stdout ) {
+ lastfont = font;
+ lastsubfont = subfont;
+ lastsize = size;
+ lastfractsize = fractsize;
+ lasthorscale = horscale;
+ if ( seenfonts[fnum] == 0 ) {
+ documentfonts();
+ }
+ if (fontname[font].afm && fontname[font].afm->encmap == NULL)
+ fontname[font].afm->encmap = printencvector(fontname[font].afm);
+ seenfonts[fnum] = 1;
+ } /* End if */
+
+ if (cmd == 'f' || cmd == 's' || cmd == 'h') {
+ if (size != FRACTSIZE)
+ fprintf(tf, "%d ", pstab[size-1]);
+ else
+ fprintf(tf, "%g ", (double)fractsize);
+ }
+ if (fontname[font].afm && cmd == 'F') {
+ if (subfont)
+ fprintf(tf, "&%s@%d\n", fontname[font].afm->Font.intname, subfont);
+ else
+ fprintf(tf, "&%s\n", fontname[font].afm->Font.intname);
+ cmd = 0;
+ } else if (cmd == 'f' || cmd == 'F' || cmd == 'h') {
+ if (fontname[font].afm && subfont)
+ fprintf(tf, "@%s@%d ", fontname[font].afm->Font.intname, subfont);
+ else if (fontname[font].afm)
+ fprintf(tf, "@%s ", fontname[font].afm->Font.intname);
+ else
+ fprintf(tf, "%s ", fontname[font].name);
+ }
+ if (cmd == 'h')
+ fprintf(tf, "%g ", horscale);
+ if (cmd)
+ fprintf(tf, "%c\n", cmd);
+
+ if ( fontname[font].fontheight != 0 || fontname[font].fontslant != 0 ) {
+ if (size != FRACTSIZE)
+ fprintf(tf, "%d %g changefont\n", fontname[font].fontslant, (fontname[font].fontheight != 0) ? (double)fontname[font].fontheight : pstab[size-1]);
+ else
+ fprintf(tf, "%d %g changefont\n", fontname[font].fontslant, (fontname[font].fontheight != 0) ? (double)fontname[font].fontheight : (double)fractsize);
+ }
+
+ if (tracked < 0 || tracked > 0 && forceflush)
+ t_strack();
+
+} /* End of t_sf */
+
+
+/*****************************************************************************/
+
+
+void
+t_charht (
+ int n, float f /* use this as the character height */
+)
+
+
+{
+
+
+/*
+ *
+ * Remembers the requested height, from 'x H n'. Forces a call to t_sf(), which
+ * is where the real work is done, by setting lastfont to -1.
+ *
+ */
+
+ if (n == FRACTSIZE)
+ fontname[font].fontheight = f;
+ else
+ fontname[font].fontheight = (n == pstab[size-1]) ? 0 : n;
+ lastfont = lastsubfont = -1;
+
+} /* End of t_charht */
+
+
+/*****************************************************************************/
+
+
+void
+t_slant (
+ int n /* slant characters this many degrees */
+)
+
+
+{
+
+
+/*
+ *
+ * Remembers the requested slant, from 'x X n'. Forces a call to t_sf(), which
+ * is where the real work is done, by setting lastfont to -1.
+ *
+ */
+
+ fontname[font].fontslant = n;
+ lastfont = lastsubfont = -1;
+
+} /* End of t_slant */
+
+/*****************************************************************************/
+
+
+void
+t_reset (
+ int c /* pause or restart */
+)
+
+
+{
+
+
+/*
+ *
+ * Found an "x stop" or "x pause" command. Although nothing's done here we could
+ * add code to reset everything so dpost could handle multiple files formatted for
+ * different devices.
+ *
+ */
+
+
+} /* End of t_reset */
+
+
+/*****************************************************************************/
+
+
+void
+t_trailer(void)
+
+
+{
+
+
+/*
+ *
+ * Called after we find an "x trailer" in the input file. Forcing out the last
+ * page is done at the end of conv(), but probably belongs here.
+ *
+ */
+
+
+ endtext();
+
+} /* End of t_trailer */
+
+
+/*****************************************************************************/
+
+
+void
+hgoto (
+ int n /* new horizontal position */
+)
+
+
+{
+
+
+/*
+ *
+ * Want to be at this absolute horizontal position next. Actual motion commands
+ * are generated in oput(), charlib(), and the drawing routines.
+ *
+ */
+
+
+ hpos = n;
+
+} /* End of hgoto */
+
+
+/*****************************************************************************/
+
+
+void
+hmot (
+ int n /* move this far horizontally */
+)
+
+
+{
+
+
+/*
+ *
+ * Handles relative horizontal motion. troff's current positon, as recorded in
+ * in hpos, is changed by n units. Usually called right before we're supposed to
+ * print a character.
+ *
+ */
+
+
+ hpos += n;
+
+} /* End of hmot */
+
+
+/*****************************************************************************/
+
+
+void
+vgoto (
+ int n /* new vertical position */
+)
+
+
+{
+
+
+/*
+ *
+ * Moves vertically in troff's coordinate system to absolute position n.
+ *
+ */
+
+
+ vpos = n;
+
+} /* End of vgoto */
+
+
+/*****************************************************************************/
+
+
+void
+vmot (
+ int n /* move this far vertically */
+)
+
+
+{
+
+
+/*
+ *
+ * Handles relative vertical motion of n units in troff's coordinate system.
+ *
+ */
+
+
+ vpos += n;
+
+} /* End of vmot */
+
+
+/*****************************************************************************/
+
+
+void
+xymove (
+ int x,
+ int y /* this is where we want to be */
+)
+
+
+{
+
+
+/*
+ *
+ * Makes sure the post-processor and printer agree about the current position.
+ *
+ */
+
+
+ hgoto(x);
+ vgoto(y);
+
+ fprintf(tf, "%d %d m\n", hpos, vpos);
+
+ lastx = hpos;
+ savey = lasty = vpos;
+
+} /* End of xymove */
+
+
+/*****************************************************************************/
+
+
+void
+put1s (
+ register char *s /* find and print this character */
+)
+
+
+{
+
+
+ static int i = 0; /* last one we found - usually */
+
+
+/*
+ *
+ * *s points to the start of a two character string that represents one of troff's
+ * special characters. To print it we first look for *s in the chname[] array using
+ * chtab[i] to find the string representing character i in chname[]. If the lookup
+ * is successful we add 128 to i and ask put1() to finish printing the character.
+ * We remember the index where the last character was found because requests to
+ * print a special character often come in bunches (eg. drawing lines with \(ru).
+ *
+ */
+
+
+ if (s[0] == 'P' && s[1] == 'S' && s[2] != 0) { /* PostScript name */
+ int m;
+ struct namecache *np;
+ struct afmtab *a;
+ if ((a = fontname[font].afm) != NULL &&
+ (np = afmnamelook(a, &s[2])) != NULL &&
+ ((m = np->fival[0]) != NOCODE ||
+ (m = np->fival[1]) != NOCODE)) {
+ put1(m+32);
+ return;
+ }
+ }
+ if ( strcmp(s, &chname[chtab[i]]) != 0 )
+ for ( i = 0; i < nchtab; i++ )
+ if ( strcmp(&chname[chtab[i]], s) == 0 )
+ break;
+
+ if ( i < nchtab )
+ put1(i + 128);
+ else i = 0;
+
+} /* End of put1s */
+
+
+/*****************************************************************************/
+
+
+void
+put1 (
+ register int c /* want to print this character */
+)
+
+
+{
+
+
+ register int i = 0; /* character code from fitab */
+ register int j; /* number of fonts we've checked so far */
+ register int k; /* font we're currently looking at */
+ int *pw = NULL; /* font widthtab and */
+ unsigned short *p = NULL; /* and codetab where c was found */
+ int code; /* code used to get c printed */
+ int ofont; /* font when we started */
+
+
+/*
+ *
+ * Arranges to have character c printed. If c < 128 it's a simple ASCII character,
+ * otherwise it's a special character. Things done here have to agree with the way
+ * the font tables were built by makedev, and work as follows. First we subtr