home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2094 / LASERFONTS
Text File  |  1990-12-28  |  7KB  |  168 lines

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