home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume24 / psroff3.0 / part12 / LASERFONTS
Encoding:
Text File  |  1991-10-09  |  7.6 KB  |  175 lines

  1.     How to build Fonts and Width Tables for your Laserjet
  2.             2.3 91/04/02
  3.  
  4. This readme presents a general discussion on how to build fonts
  5. for psroff.  The first part gives a complete description of what
  6. needs to be done/how it's done, and you can skip to the second
  7. part "AUTOMATING THE WHOLE DURN THING" if you want to use my facilities
  8. for doing all this stuff without really needing to understand what's
  9. happening.  This document does NOT directly apply to use with a Laserjet
  10. III, because the built-in fonts are used.
  11.  
  12. Psroff has been designed to work with HP SFP or TeX PK format files.
  13. Most fonts are called "normal" (Eg: R, I, B, etc.) which means that
  14. they have ROMAN8 encodings.  Thus, HP SFP ROMAN8 SFP fonts can be
  15. used as-is for psroff normal fonts (aside from copying them from
  16. floppy, giving them the right names, building width tables).
  17. On the other hand, the troff "S" font is a special font that I
  18. supply which has (nominally) MATH8 encodings.
  19.  
  20. If you can obtain HP fonts, either as soft fonts on floppy or the
  21. Laserjet III scalable fonts plus PC program to scale them to given
  22. size, you just generate the fonts you want at the CAT troff sizes
  23. and then copy them to FONTDIR/lib/lj, fix lj.fonts and do a
  24. "make register" and "make installwidths"
  25.  
  26. Knuth's TeX PK fonts cannot be used "out-of-the-box" because the
  27. character encodings are different, and the characters that psroff
  28. needs are scattered across many different fonts.
  29.  
  30. Do not despair, all is not lost - you can run psroff *purely* with
  31. TeX fonts, with the help of a little pk2* magic.  The supplied
  32. S font is an example of the result of this, and the S fonts contain
  33. a few characters you'll need if you wish to build your own fonts.
  34.  
  35. In the subdirectory utils, there are several important tools:
  36.  
  37.     1) pk2sfp - which converts PK's and SFP's into SFP's,
  38.        merging multiple ones and possibly with encoding changes.
  39.     2) pk2ditwid - which reads a font file and generates
  40.        font width information.
  41.     3) maps/* - encoding files for converting from PK encoding
  42.        to ROMAN8/MATH8 encodings.
  43.     4) fonts/* - sample fonts.
  44.  
  45. (The following discussion assumes that you've built and installed
  46. psroff).
  47.  
  48. First, examine utils/Makefile entry "buildcmtrf".  If you run this,
  49. the Makefile will create several cmtrf*.sfp files under the fonts
  50. subdirectory.  These cmtrf files are a subset of Rick Richardson's
  51. "cmtrf" font which contains characters not in TeX's PK files that you
  52. will need to build fonts for psroff.  Rick has graciously permitted
  53. distribution of the cmtrf font with psroff, and I've placed the characters
  54. in the distributed S font.  Buildcmtrf uses the "-m" option of pk2sfp
  55. (see the manual page) to extract characters named in maps/S.cmtrf
  56. ("S-font-to-CMTRF") and produce cmtrf<pointsize>.sfp files.
  57.  
  58. Next, examine utils/Makefile entry "testmerge".  What this does is
  59. run "pk2sfp -m" to generate several different fonts at the 10 point
  60. size.  "testmerge" also invokes sfp2pk (if you have it - it comes
  61. with Rick's jetroff package) to convert the resultant SFP to PK format.
  62. Each font created by testmerge is a combination of several different
  63. PK fonts.  The invocations of "pk2sfp -m" consist of something like:
  64.  
  65.     pk2sfp -m <mapfile> <fontfile> <mapfile> <fontfile>....
  66.  
  67. Where each map file contains a description of what character in the
  68. following fontfile is needed and what encoding should be used.  The
  69. naming convention of these map files is:
  70.  
  71.     <from>.<to>
  72.  
  73. Where "from" is usually a PK font name (eg: "cmtrf") and "to" is usually
  74. either ROMAN8 (for normal fonts) or MATH8 (for symbol fonts).
  75.  
  76. This is how the 10 point R font was built:
  77.     ./pk2sfp -m -v \
  78.         maps/cmr.ROMAN8 \
  79.         fonts/cmr10.pk \
  80.         maps/cmsy.ROMAN8 \
  81.         fonts/cmsy10.pk \
  82.         maps/cmtrf.ROMAN8 \
  83.         fonts/cmtrf10.sfp \
  84.         maps/cmti.ROMAN8 \
  85.         fonts/cmti10.pk \
  86.         > fonts/R.10.sfp 2> fonts/R.10.LOG
  87.  
  88. A combination of cmr, cmsy, cmtrf, cmti.
  89.  
  90. NOTE: psroff will work equally well with SFP's and PK's.  There is
  91. a substantial space advantage to converting SFP's to PK's (if you have
  92. sfp2pk), but it is *not* necessary.  Further, you can always compress
  93. your SFP's in place, and psroff will automatically invoke compress
  94. when it needs to read them.  It's only important that you get the
  95. naming convention correct (<troffname>.<pointsize>.<pk|sfp>) and
  96. the lj.fonts file set correctly.
  97.  
  98. So, the testmerge entry of the utils/Makefile creates R, I, B, C, S,
  99. H, etc fonts at 10 points.  Only 10 points.  You could operate
  100. with these only - but you'd only have one size.  Yuck.  (I distribute
  101. R, I, and B only at 10 points so that you can see that psroff actually
  102. works and not get discouraged before trying to obtain more fonts).
  103.  
  104. This is where it gets interesting.  TeX fonts usually come (as in the
  105. U of T distribution) in the following naming format:
  106.  
  107.     <TeX Name><designsize>.<resolution>pk
  108.  
  109. Eg: cmr10.329pk.  What this means that if the characters were printed
  110. on a device with a resolution of 329 dots/inch, the characters would
  111. be 10 points high.  However, the Laserjet is 300 DPI, right?  If you
  112. were to print the font at 300 DPI, the characters would appear to
  113. be (329/300 * 10) points = 10.996... points (11 with a small error),
  114. wouldn't they?  Thus, you could use cmr10.329pk to generate a 11 point
  115. font.
  116.  
  117. [NOTE: if the resolution is omitted, it is assumed to be 300 DPI -
  118. as in the utils/fonts subdirectory]
  119.  
  120. By finding cmti and cmsy (cmtrf11.sfp was built by buildcmtrf
  121. remember?) in the same fashion where the design size and DPI are *close*
  122. to 11, you can build the R font at 11 points simply by substituting
  123. the "fonts/*" names in the pk2sfp -m command line with the appropriate
  124. font names (the map files don't change).  Thus, you can build R, I, B
  125. in several different point sizes.  Note: sometimes you can't find
  126. a TeX font with a DPI/pointsize close enough to the desired point size.
  127. The S fonts were built with a maximum error of approximately 7%.
  128.  
  129. AUTOMATING THE WHOLE DURN THING:
  130.  
  131. There is a perl script in utils called "calcfonts", which if invoked
  132. in the top level make via:
  133.  
  134.     make buildljfonts
  135.  
  136. Will traverse every directory you've specified for PKFONTS during
  137. configuration of the top-level-makefile, select the best fit for
  138. each font size, and build as many psroff font files as it can, placing
  139. each font in $NEWFONTS.  Preferably you should have a sfp2pk utility
  140. (so that the fonts can be created as pk's - specify in the Makefile),
  141. but if you don't SFP's will be generated.  $NEWFONTS/lj.fonts.new
  142. will contain some new replacement entries for your lj.fonts file (make
  143. sure that the order is R, I, B and S).
  144.  
  145. After running buildljfonts, issue:
  146.  
  147.     su root
  148.     make installljfonts
  149.     ^D
  150.     make register
  151.     su root
  152.     make installwidths
  153.  
  154. The first make will install all of the new laserjet fonts in utils/newfonts.
  155. The second builds the width tables all over again, and the third reinstalls
  156. the width tables.
  157.  
  158. calcfonts can be user-modified to emit more fonts.  Near the end there
  159. are "do gen" invocations, eg:
  160.  
  161.     do gen("troffname", "English name", "HPLJ escape sequence", "set",
  162.     "pkname", "pkname", ....);
  163.  
  164. Troffname is the name that the font will be known by to psroff/troff.
  165. English name and HPLJ escape sequence are for the lj.fonts file.
  166. Each "pkname" is the name of a PK format file used to generate part of
  167. the font, and will be MERGED with the map file called "pkname.set".
  168. "set" should always be ROMAN8 (except for building S fonts when it
  169. should be MATH8).  If the pkname contains a slash (eg: cmr/foo), it
  170. means merge cmr PK's using the second token as the map name.  Eg:
  171. "cmr/foo" means merge cmr's using "foo.set".  The escape sequence is
  172. only used if you've selected a point size which is marked "b" (builtin),
  173. or is marked "n" (non-existent), and the bestmatch code in lj.c didn't
  174. find an existing font (same typeface) at a "close enough" pointsize.
  175.