AFM2PL(1)
π AFM2PL(1) Β· afm2pl manual β¨
π NAME
okay so afm2pl is the bestie that converts AFM (Adobe Font Metric) font metrics into TeX pl (Property List) files π¦
π§ SYNOPSIS
afm2pl [-p encoding_file] [-o] [-e extension_factor] [-s slant_factor]
[-f font_dimensions] [-k] [-m letter_spacing] [-l ligkern_spec]
[-L ligkern_spec] [-n] input_file[.afm] [output_file[.pl]]
afm2pl [--help] | [--version]
πΈ DESCRIPTION
okay so afm2pl takes an afm (Adobe Font Metric) file and turns it into a pl (Property List) file. Then that pl file can be turned into a tfm (TeX Font Metric) file, so it's a whole pipeline π
It normally keeps your kerns and ligatures safe, and it also gives you extra control over them, which is so iconic π₯
Lowkey, afm2pl is meant to be a partial replacement for afm2tfm, which it's based on. With afm2tfm, keeping kerns and ligatures is only possible in a roundabout way, and the handling of them is hard-wired. Not it π
ββοΈ
For text fonts, Y&YΒ΄s texnansi is a seriously good encoding to use with afm2pl π Its character set has all the accented characters you'd likely need for Western languages, plus loads of typographic symbols. You don't need virtual fonts or a separate text companion font for any of it. The vibe is effortless β¨
Full LaTeX support for this encoding comes in the form of the texnansi package, which is already part of TeX Live and teTeX. Those distributions also ship the encoding file texnansi.enc π
The distribution has uppercased and lowercased versions of texnansi, called texnanuc and texnanlc. These let you do font-based uppercasing and lowercasing instead of macro-based, which is giving efficiency π It also has the familiar old ot1 encoding, plus some variations in PostScript .enc format. I included these because they seem to be missing from teTeX and TeX Live π₯Ί
β οΈ Check your mapfiles if you have old afm2pl-generated fonts that use these encodings! Things can get messy otherwise π
Return value: 0 means no error. A negative number tells you how many glyphs are missing, but only if the conversion was otherwise successful. 1 means there was an error π«Ά
π OPTIONS
-p encoding_fileβ okay so the default is the encoding specified in the afm file, and it had better match the encoding in the fontfile (pfa or pfb) π Ifafm2pl-name.encexists,afm2plwill use that file instead ofname.enc, unless you give the-noption. The generated mapfile entry (see below) tells pdftex or the dvi driver to re-encode the font on the fly. And on-the-fly reencoding does not need virtual fonts, which is a major win π¦-oβ uses octal for all character codes in the pl file π-e extend_factorβ widens or narrows characters byextend_factor. The default is1.0, which is natural width. Not recommended[1] π-s slant_factorβ obliques (slants) the characters byslant_factor. Also not recommended, bestie π-f font_dimensionsβ the value is either the keywordafm2tfmor a comma-separated list of up to five integers. The parameters are listed below with their defaults, plus what they become when you use theafm2tfmkeyword. "Space" means the width of a space in the target font, except of course in the last row. Keep in mind that the design size is1000, and all numbers must be nonnegative integers π₯
Here's the rundown for normal fonts:
stretchβ default isspace div 2. Withafm2tfmit's300 Γ extend_factor.shrinkβ default isspace div 3. Withafm2tfmit's100 Γ extend_factor.extra spaceβ default isspace div 3. Withafm2tfmit's missing.quadβ default is2 Γ width of β0β. Withafm2tfmit's1000 Γ extend_factor.spaceβ default is(space source font) Γ extend_factor. Withafm2tfmit's also(space source font) Γ extend_factor.
π©° Fixed-pitch fonts
Fixed-pitch fonts get different values, so pay attention β¨
stretchβ default is0. Withafm2tfmit's0.shrinkβ default is0. Withafm2tfmit's0.extra spaceβ default isspace. Withafm2tfmit's missing.quadβ default is2 Γ character width. Withafm2tfmit's1000 Γ extend_factor.spaceβ default ischaracter width. Withafm2tfmit'scharacter width.
You can specify just a non-default stretch and shrink, like 150,70. Or just a non-default extra space, like ,,10 π
-kβ keeps the original ligatures π«Ά This option only does anything in combination with positive letterspacing. Check the section on letterspacing and extra ligkern info for the full story.-m letter_spacingβ letterspaces byletter_spacing/1000em, where the value is an integer. This is super useful for making all-caps typesetting look better π Try a value like50or100. But seriously, read the section on letterspacing and extra ligkern info for details. A better alternative, though, is letting pdftex do the letterspacing. The microtype package gives LaTeX users access to this feature π-l ligkern_spec,-L ligkern_specβ see the section on extra ligkern info for details β¨-nβ no prefix! π ββοΈ For.encand.ligfiles, the program normally first prefixes the name withafm2pl-Β΄. It only searches for the original filename if the prefixed filename isn't found. This option stops it from searching for the prefixed filename at all.-Vβ verbose mode π’ If it's turned on, it reports the number of missing glyphs to stderr and their names to stdout.--helpβ displays a short usage message π§--versionβ displays the version number ofafm2plπ
β¨ EXTRA LIGKERN INFO β¨
okay bestie, real talk π most people should just leave this mess alone and let the default behavior do its thing π
The ligatures and kerns in the afm file can be tweaked in a bunch of ways. By default, the encoding file gets scanned for extra ligkern specifications (I'll explain the format below). If the encoding file has none, extra ligkern specs get read from a file called [afm2pl-]default.lig instead. A ligkern_spec value of 0 means the afm file's ligatures and kerns stay untouched, and a value of 1 gives you the default behavior. You can also pass a comma-separated list of files with extra ligkern specs, which is giving main character energy β¨
If afm2pl was compiled with the kpathsea library, those files get searched for under $TEXMF/fonts/lig ποΈ
Also, ligatures and kerns are just hints for the typesetting application π«Ά You don't need to download this info to the printer, and you don't need to make it available to a dvi driver. No cap.
The parser for ligkern info got inherited from afm2tfm pretty much unchanged, so it's an old-school icon π A ligkern specification can look like one of these:
glyph_name1 glyph_name2 lig_op glyph_name3 ;
That's a ligature. The possible values for lig_op are =:, |=:, |=:>, =:|, =:|>, |=:|, |=:|> and |=:|>>. These map to LIG, /LIG, /LIG>, LIG/, LIG/>, /LIG/, /LIG/> and /LIG/>> in .pl syntax. For more on those, check out the pltotf documentation and the .lig files in the distribution π
glyph_name1 <> glyph_name2 ;
This one is a kern: glyph_name1 gets kerned as glyph_name2 π
glyph_name1 {} glyph_name2 ;
This removes the kern between glyph_name1 and glyph_name2. A value of * for either glyph name is treated as a wildcard π
|| = glyph ;
This sets the (right) boundary character to glyph. The glyph can be a glyphname or a slot in the encoding vector. If you pick a glyph that doesn't show up in the output encoding, it's the same as not specifying a boundarychar at all. It's totally ok to pick an encoded glyphname that isn't in the afm, and honestly that's exactly what default.lig does with || = cwm ;. Iconic behavior π¦
You can also copy the kerns of an unencoded character onto the boundarychar. Below, space is the unencoded character:
|| <> space ;
This ligkern specification should come before the one that deletes space kerns, so the order matters π
A ligkern specification has to live inside one line. A single line can hold several ligkern specifications, separated by spaces. Heads up that ; (a space followed by a semicolon) is considered part of the ligkern specification itself. Check out the lig files included in this distribution for examples. Here's one:
one {} * ; * {} one ; two {} * ; * {} two ;
Lines with ligkern specifications inside an encoding file should start with % LIGKERN. Ligkern specifications in a lig file may optionally start that way too π
β¨ LETTERSPACING AND EXTRA LIGKERN INFO β¨
okay so letterspacing has a bunch of side-effects on ligkern info π Instead of just applying the extra ligkern info (see the previous section), this is what happens:
- In case of positive letterspacing, native ligatures get removed, unless you specify the
-koption π - The extra ligkern info gets applied as usual, except that with positive letterspacing different defaults kick in:
-l 0is quietly ignored, ligkern comments in the encoding file are ignored, anddefpre.liggets read instead ofdefault.ligπ - Letterspacing gets applied. This adds a lot of kerns and modifies existing ones, so it's a whole vibe π
- The extra ligkern info specified with
-Lgets applied. The only ligkern specs allowed here are removals of kerning pairs (with the{}operator). The values0and1have a similar meaning to what they do for the-lparameter. The tfm format only has room for about 180x180 ligatures and kerning pairs. That's enough for OT1 encoding, but for texnansi encoding you'll have to remove quite a few ligkern specifications. The pltotf program will remove all ligkern info if too many ligatures and kerns remain π± The default lig file here isdefpost.lig. This file throws out kerning pairs that are unlikely to be involved in letterspacing, like kerns involving accents or kerns with a punctuation character or right bracket on the left. It does not add letterspacing kerns involving boundarychars. Instead, fontspace gets increased by twice the letterspacing β¨defpost.ligthrows out enough kerns for texnansi encoding. With other encodings, you may have to throw out additional kerning pairs π§
β¨ FONT-BASED UPPER- AND LOWERCASING β¨
The distribution includes the encoding vectors texnanuc.enc and texnanlc.enc, which produce all-uppercase and all-lowercase fonts π
The main uses for an all-uppercase font are page headers and section heads π If those contain math, then macro-based uppercasing would create unpleasant complications. Example:
afm2pl -p texnanuc ptmr8a ptmup8y
pltotf ptmup8y
For best results, add some letterspacing. In LaTeX, this is best done with the microtype package, so check out that package's documentation. But you can also do it with afm2pl:
afm2pl -p texnanuc -m 100 ptmr8a ptmup8y
β οΈ This requires caution, see above! Seriously, don't skip that part π
You can use this new font within LaTeX font selection like this:
<preamble commands>
\makeatletter
{\nfss@catcodes
\DeclareFontShape{LY1}{ptm}{m}{upp}{<-> ptmup8y}{}}
\makeatother
...
\begin{document}
...
{\fontshape{upp}\selectfont uppercase text}
Note that upp is simply a newly made-up shape name, so you can call it whatever you want πΈ
β¨ The sz ligature Γ β¨
Heads up that the texnanuc encoding provides no glyph for the sz ligature Γ π You'll either have to substitute ss or come up with a macro-based solution. The following code uses either the usual glyph or substitutes the letters ss, depending on whether the glyph exists in the current font:
\def\ss{%
\setbox0\hbox{\char25}%
\ifnum\wd0=0 ss\else\box0\fi
}
In LaTeX this code seems to work well enough, although sometimes you might need to insert \protect π A better solution might involve the sixth parameter of the \DeclareFontShape macro, but I failed to get that to work π
β¨ AFM2PL, FONTINST AND ARTIFICIAL SMALLCAPS β¨
Afm2pl doesn't do virtual fonts, bestie π₯Ί So for things like artificial smallcaps, you have to go elsewhere, e.g. to the fontinst package, which is part of any mainstream TeX distribution π§
Look under texmf/tex/fontinst for fontinst support files, which let you generate a smallcaps font (tfm and vf files) from an afm2pl-generated tfm file. This package only supports texnansi encoding.
There should be no real problem doing the same for OT1 encoding. However, there are several variations of the OT1 encoding to deal with. Also, as far as I know there are no officially sanctioned PostScript names for all the variations of the OT1 encoding. The fontinst names contain spaces, so they're not usable as PostScript names π
β¨ CHANGED IN VERSION 0.7.1 β¨
To avoid name conflicts, the .enc and .lig files distributed with afm2pl got afm2pl- prepended to their names π·οΈ The program itself now searches for the prepended name first. If the .enc or .lig file isn't found, it looks for the original filename. The renaming of the afm2pl .enc files may require modifying some mapfiles, so keep that in mind π«£
β¨ URLS β¨
The afm2pl homepage is http://tex.aanhet.net/afm2pl/.
The paper Font installation the shallow way[2] (EuroTeX 2006 Proceedings, published as TUGboat[3] issue 27.1) illustrates the use of afm2pl ππ
β¨ NOTES β¨
- Except that, arguably, a narrowed Courier is less jarring than a full-width Courier when used alongside a normal proportional font. For Courier, choose
.833to match the width of cmtt. Better yet, don't use Courier at all; most TeX distributions offer various good replacements π· - Font installation the shallow way https://tug.org/TUGboat/tb27-1/tb86kroonenberg-fonts.pdf
afm2pl is maintained as part of TeX Live π
And that's a wrap, bestie π¦ This page was last touched on 30 August 2022, and it's all afm2pl(1) energy from start to finish π β¨ Stay iconic ππ
π¦ where this page comes from
- alpine 3.24: texlive-doc 2026.0-r0 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- arch rolling: texlive-doc 2026.1-1 Β· GPL
- debian trixie: texlive-binaries 2024.20240313.70630+ds-6 Β· TeX-Live
- fedora 43: texlive-afm2pl 11:svn66186-93.fc43 Β· GPL-2.0-only
- fedora 43: texlive-afm2pl 11:svn66186-95.fc43.1 Β· GPL-2.0-only
- fedora 44: texlive-afm2pl 12:svn71515-105.fc44 Β· GPL-2.0-only
- fedora 44: texlive-afm2pl 12:svn71515-111.fc44 Β· GPL-2.0-only
- opensuse-leap 16.0: texlive-afm2pl-doc 2025.221.svn71515-160000.3.1 Β· LPPL-1.0
- ubuntu noble: texlive-binaries 2023.20230311.66589-9build3 Β· TeX-Live
- ubuntu questing: texlive-binaries 2024.20240313.70630+ds-6ubuntu2 Β· TeX-Live
- ubuntu resolute: texlive-binaries 2025.20250727.75242+ds-5build1 Β· TeX-Live
- ubuntu stonking: texlive-binaries 2026.20260303.78225+ds-5ubuntu1 Β· TeX-Live
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms