Surviving The TeX Font Encoding Mess
Surviving The TeX Font Encoding Mess
Surviving The TeX Font Encoding Mess
COROLLARY:
TEX fonts are mess, as they are a product of reality.
Similary, fontinst is a mess, not necessarily by design,
but because it has to cope with the mess we call reality.
Contents
• in technical terms:
– fonts have many different representations depending on the point of view
– TEX typesetter: fonts metrics (TFM) and nothing else
– DVI driver: virtual fonts (VF), bitmaps fonts(PK), outline fonts (PFA/PFB or TTF)
– PostScript: Type 1 (outlines), Type 3 (anything), Type 42 fonts (embedded TTF)
• in general terms:
– fonts are collections of glyphs (characters, symbols) of a particular design
– fonts are organized into families, series and individual shapes
– glyphs may be accessed either by character code or by symbolic names
– encoding of glyphs may be fixed or controllable by encoding vectors
• font information consists of:
– metric information (glyph metrics and global parameters)
– some representation of glyph shapes (bitmaps or outlines)
• PostScript font names are given in verbose format (32 chars) like this:
FamilySupplier-SeriesShapeVariant
• PostScript fonts are named according to vendor-specific naming schemes
• TEX fonts are named according to Karl Berry’s font name scheme like this:
S FF W [V] EE [W] [DD]
• How the Berry font name scheme is composed:
S: supplier, FF: family, W: weight, V: variants (as needed),
EE: encoding, W width (if any), DD: design size (if any)
• Problems of the Berry font name scheme:
– designed to be compatible with 8+3 file systems (more or less)
– limited to no more than 26 suppliers and 26×36 families
– all meaningful supplier and family codes are already taken
– no one-to-one mapping of weights onto LATEX font selection codes
– distinction between shapes, design and encoding variants is messy
Berry font names and LATEX weight codes: Berry font names and LATEX width codes:
a Thin, Hairline ul Ultra Light t Thin – –
j ExtraLight el Extra Light o Ultra Condensed uc Ultra Condensed
l Light l Light u Ultra Compressed uc . .
r Regular, Roman m Medium q Extra Compressed ec Extra Condensed
k Book m Medium c Condensed c Condensed
m Medium mb (was: m) p Compressed c ..
d Demi db (was: sb) n Narrow c ..
s Semibold sb Semibold – – sc Semi Condensed
b Bold b Bold r Normal, Regular m Medium
h Heavy eb (was missing) – – sx Semi Expanded
c Black eb (was missing) e Expanded x Expanded
x Extra, ExtraBlack eb Extra Bold x Extended x ..
u Ultra, UltraBlack ub Ultra Bold v Extra Expanded ex Extra Expanded
p Poster – (still missing) – – ux Ultra Expanded
w Wide – –
• 8r and 8y both provide full access to all glyphs available in standard fonts
• 8r and 8y are based on ASCII (32–127) and Latin 1 (160-255)
• 8r and 8y differ in placement of extra glyphs and symbols
• 8r and 8y include slots for ff-ligatures (usually absent from standard fonts)
• 8r is widely used for raw fonts in CTAN metrics since 1995
• 8y is proposed as an alternative approach by Y&Y (“8y is 8r done right”)
• 8r is only used as a raw font encoding, not directly for typesetting
• 8y is also used as a LATEX output encoding for typesetting (LY1)
• 8y mostly follows OT1 layout in lower half (including some glyphs twice)
• 8y avoids complications of T1, TS1 regarding non-standard glyphs
• 8y is functionally equivalent or even superior to 8r for standard glyphs
• 8y still requires virtual fonts to make use of expert glyphs
• LY1 may be the best choice for Latin 1, but T1 also supports Latin 2
• PostScript fonts: Have AFM files ready or convert PFM files to AFM files
• TrueType fonts: Extract font metrics to AFM files using ttf2afm
• Install font metrics (AFM) and font programs (PFA/PFB or TTF)
• Reencode fonts to raw encoding (8r or 8y) to make all glyphs accessible
• Transform raw fonts as needed to fill missing shapes (SlantFont)
• Generate TEX font metrics (TFM) for each reencoded or transformed font
• Generate virtual fonts (VF, TFM) to implement usual TEX encodings
• Install generated font metrics (TFM) and virtual fonts (VF, TFM)
• Generate and install font definition files (*.fd) for LATEX
• Generate or update font map files for dvips and pdftex
• What is fontinst?
– a general-purpose utility for (PostScript) font installation
– developed by Alan Jeffrey, now maintained by volunteer group
– development coordinated through fontinst mailing list
• Features of fontinst:
– written entirely in TEX for portability at the cost of speed
– operates on font metric information in textual format
– reads AFM or PL files and writes out PL or VPL files
– uses ETX files to specify source and target encodings
– uses MTX files to record metric and kerning information
– allows reencoding, transforming and scaling fonts as needed
– supports installation of reencoded and transformed raw fonts
– supports installation of virtual fonts based on raw fonts
– allows manipulating glyph metrics and kerns through MTX files
• Overview of \transformfont:
– converts font metrics to internal fontinst format (MTX files)
– reads font metrics from existing MTX files, AFM files or PL files
– supports reencoding and geometric transformations of font metrics
• Syntax of \transformfont:
\transformfont{<font>}{<commands>} % writes transformed MTX
\frommtx{<font>} % reads from existing MTX
\fromafm{<font>} % reads from AFM, writes MTX and PL
\frompl {<font>} % reads from PL, writes MTX
• Examples of \transformfont:
\transformfont{ptmr8r} {\reencodefont{8r}{\fromafm{ptmr8a}}}
\transformfont{ptmro8r} {\slantfont{167}{\frommtx{ptmr8r}}}
• Overview of \installfamily:
– grouped between \installfonts and \endinstallfonts
– initializes a token list, in which *.fd information is recorded
– *.fd entries are recorded for each \installfont command
– *.fd entries are written out when \endinstallfonts is processed
• Syntax of \installfamily:
\installfamily {<enc>}{<family><variant>}{}
• Examples of \installfamily:
\installfamily {8r}{pmn}{} % standard family
\installfamily {8r}{pmnx}{} % expertized family
\installfamily {8r}{pmnj}{} % oldstyle family
• Overview of \latinfamily:
– attempts to do an automatic installation of a given font family
– supports standard, expertized, or expertized oldstyle installations
– installs 8r (or 8y) raw fonts as well as 8x expert fonts
– installs OT1, T1 and TS1 virtual fonts
– installs all available font series (weights) for standard font shapes
– installs faked small caps if real small caps are not available
• Syntax of \latinfamily:
\latinfamily {<family><variant>}{}
• Examples of \latinfamily:
\latinfamily {pmn}{} % standard family: 7t, 8t, 8c
\latinfamily {pmnx}{} % expertized family: 9t, 9e, 9c
\latinfamily {pmnj}{} % oldstyle family: 9o, 9d, 9c
% upright shape
\transformfont {<font>8r} {\reencodefont{8r}{\fromafm{<font>8a}}}
\installrawfont {<font>8r} {<font>8r,8r} {8r} {8r} {<fam>}{<series>}{n}{}
% italic shape
\transformfont {<font>i8r}{\reencodefont{8r}{\fromafm{<font>i8a}}}
\installrawfont {<font>i8r}{<font>i8r,8r} {8r} {8r} {<fam>}{<series>}{it}{}
• standard + expert:
– OT1c.etx references slots for small caps glyphs
– <font>8r.mtx provides metrics for standard glyphs
– <font>8x.mtx provides metrics for small caps glyphs
– latin.mtx glyph commands for small caps are ignored
• standard + expert + oldstyle:
– OT1cj.etx references slots for small caps and oldstyle figs
– <font>8r.mtx provides metrics for standard glyph
– <font>8x.mtx provides metrics for small caps and oldstyle figs
– latin.mtx glyph commands for small caps are ignored
• Non-standard installation:
– OT1c.etx, OT1cj.etx reference slots for small caps and oldstyle figs
– <font>8r.mtx provides metrics for standard glyphs
– <font>8x.mtx provides metrics for small caps glyphs
– <font>c8r.mtx provides kern pairs between uppercase and small caps
– kernoff.mtx, kernon.mtx disables and restores \setkern
– glyphoff.mtx, glpyh.mtx disables and restores \setrawglyph
– resetsc.mtx, resetosf.mtx reshuffels metrics to SC+OsF glyph names
– latin.mtx glyph commands for small caps are ignored
• \NOFILES command:
– turns \transformfont and \installfont commands into no-ops
– causes dummy files to be created for all file output commands
– may be used to diagnose which commands are issued from \latinfamily
– may be used to diagnose which files are created in a normal run
• fontinst.rc configuration file:
– may contain extra commands read at the end of fontinst.sty
– may be used to redefine the raw font encoding: \def\raw_encoding{8y}
– may be used to redefine the list of series and shapes for \latinfamily
– may be used to redefine internals of \latinfamily
• Manual installation:
– Create fontinst control file:
% file: fontppl.tex
\input fontinst.sty
\latinfamily{ppl}{}
\bye
– Run fontinst from the command line:
> fontinst fontppl.tex
> tex -progname=fontinst fontppl.tex
• Automatic installation:
– Call Perl front-end from the command line:
> perl make-fam.pl -outdir $OUTDIR/adobe/palatino ppl
• Manual installation:
– Generated PL and VPL must be converted to TFM and VF files:
> for f in *.pl; do pltotf $f; done
> for f in *.vpl; do vptovf $f; done
– Install TFM and VF files:
> cp *.tfm $TEXMF/fonts/tfm/adobe/palatino/
> cp *.vf $TEXMF/fonts/vf/adobe/palatino/
• Text fonts:
– 7-bit Computer Modern is still used by default
– switching font families is no problem with LATEX 2ε (or ConTEXt)
– switching encodings (OT1/T1/LY1) is no problem either
– metrics for common PostScript fonts are available from CTAN
– metrics for other fonts can be prepared with fontinst
– many thousands of text fonts exist in Type 1 format
• Math fonts:
– 7-bit Computer Modern is difficult to change
– very few sets of math fonts are available for use with TEX
– each math font set uses different encoding variants
– each math font set requires different macro packages
• TEXnical considerations:
– TEX interprets glyph metrics of math fonts in a peculiar way
– TFM width denotes position where subscripts are attached
– italic correction denotes position where superscripts are attached
– actual glyph width = TFM width + italic correction + sidebearings
– pseudo kern pairs with \skewchar control placement of math accents
– math fonts are organized into math families (no more than 16!)
– math fonts must have special FONTDIMEN parameters
– FONTDIMENs control placement of subscripts and superscripts
– FONTDIMENs control spacing of fractions, radicals and big operators
– glyph height of radicals determines rule thickness of bar
– big radicals must be designed to hang below baseline
– big delimiters and operators are centered on the math axis
– big delimiters and operators may be designed to be centered
– however: TFM format imposes limit of 16 heights + 16 depths
• fontinst Homepage:
http://www.tug.org/applications/fontinst/