home *** CD-ROM | disk | FTP | other *** search
- How to build Fonts and Width Tables for your Laserjet
- 2.1 90/07/18
-
- This readme presents a general discussion on how to build fonts
- for psroff. The first part gives a complete description of what
- needs to be done/how it's done, and you can skip to the second
- part "AUTOMATING THE WHOLE DURN THING" if you want to use my facilities
- for doing all this stuff without really needing to understand what's
- happening.
-
- Psroff has been designed to work with HP SFP or TeX PK format files.
- Most fonts are called "normal" (Eg: R, I, B, etc.) which means that
- they have ROMAN8 encodings. Thus, HP SFP ROMAN8 SFP fonts can be
- used as-is for psroff normal fonts (aside from copying them from
- floppy, giving them the right names, building width tables).
- On the other hand, the troff "S" font is a special font that I
- supply which has (nominally) MATH8 encodings.
-
- Knuth's TeX PK fonts cannot be used "out-of-the-box" because the
- character encodings are different, and the characters that psroff
- needs are scattered across many different fonts.
-
- Do not despair, all is not lost - you can run psroff *purely* with
- TeX fonts, with the help of a little pk2* magic. The supplied
- S font is an example of the result of this, and the S fonts contain
- a few characters you'll need if you wish to build your own fonts.
-
- In the subdirectory utils, there are several important tools:
-
- 1) pk2sfp - which converts PK's and SFP's into SFP's,
- merging multiple ones and possibly with encoding changes.
- 2) pk2ditwid - which reads a font file and generates
- font width information.
- 3) maps/* - encoding files for converting from PK encoding
- to ROMAN8/MATH8 encodings.
- 4) fonts/* - sample fonts.
-
- (The following discussion assumes that you've built and installed
- psroff).
-
- First, examine utils/Makefile entry "buildcmtrf". If you run this,
- the Makefile will create several cmtrf*.sfp files under the fonts
- subdirectory. These cmtrf files are a subset of Rick Richardson's
- "cmtrf" font which contains characters not in TeX's PK files that you
- will need to build fonts for psroff. Rick has graciously permitted
- distribution of the cmtrf font with psroff, and I've placed the characters
- in the distributed S font. Buildcmtrf uses the "-m" option of pk2sfp
- (see the manual page) to extract characters named in maps/S.cmtrf
- ("S-font-to-CMTRF") and produce cmtrf<pointsize>.sfp files.
-
- Next, examine utils/Makefile entry "testmerge". What this does is
- run "pk2sfp -m" to generate several different fonts at the 10 point
- size. "testmerge" also invokes sfp2pk (if you have it - it comes
- with Rick's jetroff package) to convert the resultant SFP to PK format.
- Each font created by testmerge is a combination of several different
- PK fonts. The invocations of "pk2sfp -m" consist of something like:
-
- pk2sfp -m <mapfile> <fontfile> <mapfile> <fontfile>....
-
- Where each map file contains a description of what character in the
- following fontfile is needed and what encoding should be used. The
- naming convention of these map files is:
-
- <from>.<to>
-
- Where "from" is usually a PK font name (eg: "cmtrf") and "to" is usually
- either ROMAN8 (for normal fonts) or MATH8 (for symbol fonts).
-
- This is how the 10 point R font was built:
- ./pk2sfp -m -v \
- maps/cmr.ROMAN8 \
- fonts/cmr10.pk \
- maps/cmsy.ROMAN8 \
- fonts/cmsy10.pk \
- maps/cmtrf.ROMAN8 \
- fonts/cmtrf10.sfp \
- maps/cmti.ROMAN8 \
- fonts/cmti10.pk \
- > fonts/R.10.sfp 2> fonts/R.10.LOG
-
- A combination of cmr, cmsy, cmtrf, cmti.
-
- NOTE: psroff will work equally well with SFP's and PK's. There is
- a substantial space advantage to converting SFP's to PK's (if you have
- sfp2pk), but it is *not* necessary. Further, you can always compress
- your SFP's in place, and psroff will automatically invoke compress
- when it needs to read them. It's only important that you get the
- naming convention correct (<troffname>.<pointsize>.<pk|sfp>) and
- the lj.fonts file set correctly.
-
- So, the testmerge entry of the utils/Makefile creates R, I, B, C, S,
- H, etc fonts at 10 points. Only 10 points. You could operate
- with these only - but you'd only have one size. Yuck. (I distribute
- R, I, and B only at 10 points so that you can see that psroff actually
- works and not get discouraged before trying to obtain more fonts).
-
- This is where it gets interesting. TeX fonts usually come (as in the
- U of T distribution) in the following naming format:
-
- <TeX Name><designsize>.<resolution>pk
-
- Eg: cmr10.329pk. What this means that if the characters were printed
- on a device with a resolution of 329 dots/inch, the characters would
- be 10 points high. However, the Laserjet is 300 DPI, right? If you
- were to print the font at 300 DPI, the characters would appear to
- be (329/300 * 10) points = 10.996... points (11 with a small error),
- wouldn't they? Thus, you could use cmr10.329pk to generate a 11 point
- font.
-
- [NOTE: if the resolution is omitted, it is assumed to be 300 DPI -
- as in the utils/fonts subdirectory]
-
- By finding cmti and cmsy (cmtrf11.sfp was built by buildcmtrf
- remember?) in the same fashion where the design size and DPI are *close*
- to 11, you can build the R font at 11 points simply by substituting
- the "fonts/*" names in the pk2sfp -m command line with the appropriate
- font names (the map files don't change). Thus, you can build R, I, B
- in several different point sizes. Note: sometimes you can't find
- a TeX font with a DPI/pointsize close enough to the desired point size.
- The S fonts were built with a maximum error of approximately 7%.
-
- AUTOMATING THE WHOLE DURN THING:
-
- There is a perl script in utils called "calcfonts", which if invoked
- in the top level make via:
-
- make buildljfonts
-
- Will traverse every directory you've specified for PKFONTS during
- configuration of the top-level-makefile, select the best fit for
- each font size, and build as many psroff font files as it can, placing
- each font in $NEWFONTS. Preferably you should have a sfp2pk utility
- (so that the fonts can be created as pk's - specify in the Makefile),
- but if you don't SFP's will be generated. $NEWFONTS/lj.fonts.new
- will contain some new replacement entries for your lj.fonts file (make
- sure that the order is R, I, B and S).
-
- After running buildljfonts, issue:
-
- su root
- make installljfonts
- ^D
- make register
- su root
- make installwidths
-
- The first make will install all of the new laserjet fonts in utils/newfonts.
- The second builds the width tables all over again, and the third reinstalls
- the width tables.
-
- calcfonts can be user-modified to emit more fonts. Near the end there
- are "do gen" invocations, eg:
-
- do gen("troffname", "English name", "HPLJ escape sequence", "set",
- "pkname", "pkname", ....);
-
- Troffname is the name that the font will be known by to psroff/troff.
- English name and HPLJ escape sequence are for the lj.fonts file.
- Each "pkname" is the name of a PK format file used to generate part of
- the font, and will be MERGED with the map file called "pkname.set".
- "set" should always be ROMAN8 (except for building S fonts when it
- should be MATH8). If the pkname contains a slash (eg: cmr/foo), it
- means merge cmr PK's using the second token as the map name. Eg:
- "cmr/foo" means merge cmr's using "foo.set". The escape sequence is
- only used if you've selected a point size which is marked "b" (builtin),
- or is marked "n" (non-existent), and the bestmatch code in lj.c didn't
- find an existing font (same typeface) at a "close enough" pointsize.
-