| OTFTOTFM(1) | General Commands Manual | OTFTOTFM(1) |
otftotfm - create TeX font metrics from OpenType fonts
otftotfm [-a] [options] fontfile [texname]
Otftotfm creates the font metric and encoding files required to use an OpenType font with TeX. You supply an OpenType ".otf" or ".ttf" font file, a base ".enc" encoding, and a TeX name "texname" for the resulting font, and say which OpenType features should be turned on. Then otftotfm generates and installs the corresponding TeX-related metric files (".tfm" TeX font metrics, ".vf" virtual fonts, and ".enc" encoding files). It works on both PostScript-flavored and TrueType-flavored OpenType fonts, although TrueType-flavor support will only work easily with pdftex.
The easiest way to use otftotfm is with the -a option; see Automatic Mode below. Without -a, otftotfm writes all its output files to the current directory.
After running "otftotfm fontfile texname" and installing the results (manually or with -a), you can use the OpenType font in plain TeX with a command like this:
\font\myfont=texname at 10pt
{\myfont This text uses the OpenType font.}
LaTeX users will generally make a ".fd" input file so that commands like "\renewcommand{\rmdefault}{TeXName}" work correctly. See the EXAMPLE section for more; check the DIAGNOSTICS and FREQUENTLY ASKED QUESTIONS sections if you have trouble.
OpenType fonts support optional features that change their appearance. Use the -f option to turn on selected features. For example, "-fsmcp" replaces lower-case letters with the corresponding small capitals, in fonts that support this.
You'll generally provide at least the "-fkern" and "-fliga" options, which activate pair kerns and f-ligatures. Other interesting features include "-fcpsp", for capital spacing; "-fdlig", for optional ligatures; "-flnum", "-fonum", "-fpnum", and "-ftnum", to control digit glyphs; "-fsmcp", for small capitals; "-fswsh", for swash variants; and "-fcswh", for contextual swash. See the FEATURE DIRECTORY section below for more. The otfinfo(1) program will report which features a font supports; run "otfinfo -f fontfile".
Feature options can also apply a feature to a subset of characters in the font. For example, "--lf smcp" only replaces letters with small capitals, whereas "-fsmcp" might additionally replace digits and punctuation marks with small-capital versions.
Automatic mode, triggered by the -a/--automatic option, installs font metrics and encoding files where TeX can find them, and additionally installs a Type 1 font and mapping for dvips(1). This requires a TeX installation that follows the TeX Directory Structure standard (http://www.tug.org/tds/), such as most Unix TeX installations.
Automatic mode should run seamlessly out of the box. Otftotfm will install metrics files, encodings, map files, and Type 1 fonts into $HOME/.texmf-var or any other writable TEXMF directory, and run updmap(1) to update the global lists of installed fonts. (On older teTeX installations, you may first need to copy the system's updmap.cfg file to $HOME/texmf/web2c and run mktexlsr(1). On newer TeXLive installations, you may need to set the TEXMFVAR environment variable.) You can then run "otftotfm -a fontfile texname" and immediately refer to the font in TeX using the texname you supplied. Again, you will have to write ".fd" files and/or typescripts to make the font conveniently accessible from LaTeX or ConTeXt. See the DIAGNOSTICS section if you have problems with these instructions.
In automatic mode, otftotfm searches your $TEXMFVAR or $TEXMF path for a writable directory, then installs files under that directory tree as follows:
| File type | Directory | Filename |
| TFM | TEXMF/fonts/tfm/vendor/typeface/ | texname[--base].tfm |
| VF | TEXMF/fonts/vf/vendor/typeface/ | texname.vf |
| PL | TEXMF/fonts/pl/vendor/typeface/ | texname[--base].pl |
| VPL | TEXMF/fonts/vpl/vendor/typeface/ | texname.vpl |
| encoding | TEXMF/fonts/enc/dvips/vendor/ | a_signature.enc |
| or TEXMF/dvips/vendor/ | ||
| font map | TEXMF/fonts/map/dvips/vendor/ | vendor.map |
| or TEXMF/dvips/vendor/ |
"TEXMF" stands for the writable TEXMF directory. Texname is the font name supplied as otftotfm's second argument. The vendor and typeface strings are required by TDS; they default to "lcdftools" and the font's family name, respectively, but see the --vendor and --typeface options. Signature is an opaque 6-character encoding signature.
Otftotfm also installs a font file suitable for printing. PostScript-flavored OpenType fonts are translated to Type 1 format and installed as PFB fonts. TrueType-flavored fonts are normally installed as is, since pdftex and pdflatex can read TrueType directly; but if you provide the --type42 option, otftotfm will translate TrueType fonts to Type 42 format, which dvips understands. Otftotfm does not overwrite existing font files.
The installation paths are as follows, where PSname is the font's PostScript name.
| PFB | TEXMF/fonts/type1/vendor/typeface/ | PSname.pfb |
| TrueType | TEXMF/fonts/truetype/vendor/typeface/ | fontfile |
| Type 42 | TEXMF/fonts/type42/vendor/typeface/ | PSname.t42 |
You can override these directories with environment variables and options as follows. Options take precedence over environment variables.
| File type | Environment variable | Option |
| TFM | TFMDESTDIR | --tfm-directory |
| VF | VFDESTDIR | --vf-directory |
| PL | PLDESTDIR | --pl-directory |
| VPL | VPLDESTDIR | --vpl-directory |
| encoding | ENCODINGDESTDIR | --encoding-directory |
| PFB | T1DESTDIR | --type1-directory |
| TrueType | TRUETYPEDESTDIR | --truetype-directory |
| Type 42 | T42DESTDIR | --type42-directory |
| font map | - | --map-file |
Otftotfm will update the TEXMF/ls-R file when installing files under TEXMF. It will also run the updmap(1) program after changing a map file, unless the --no-updmap option was supplied. However, if an executable file called TEXMF/dvips/updmap exists, this file is executed (from the TEXMF/dvips directory) rather than the global updmap. This is so you can write a fast, customized version of updmap if desired.
This section uses MinionPro to show one way to install OpenType fonts for LaTeX. We begin with six fonts: "MinionPro-Regular.otf", "MinionPro-It.otf", "MinionPro-Semibold.otf", "MinionPro-SemiboldIt.otf", "MinionPro-Bold.otf", and "MinionPro-BoldIt.otf".
Our first task is to decide how to encode the fonts. The "encoding scheme" is used by TeX to decide how to typeset accents and symbols like "$". The "LY1" encoding scheme has reasonable accent support and is a good choice for many OpenType fonts. LY1 corresponds to the "texnansx.enc" encoding file, so we will supply otftotfm with the "-e texnansx" option.
Expert note: Strictly speaking, LY1 corresponds to the "texnansi.enc" encoding file. Since the "texnansx.enc" version omits duplicate characters, it has more room for font-specific glyphs and is generally a better choice; but if you plan to type characters like "ae" directly into your editor, rather than using TeX commands like \ae, you should use "texnansi.enc".
Next, we decide on a naming scheme for the font metric files. Let's use the OpenType font names as a base. (There's generally no need to follow the six-character "Karl Berry" naming scheme.) Just in case we come back later and add a different encoding scheme, we'll prepend "LY1--" to each name.
We're now ready to run otftotfm for the first set of fonts. Note the "-fkern -fliga" options, which access pair kerns and the default "f" ligatures.
otftotfm -a -e texnansx MinionPro-Regular.otf \
-fkern -fliga LY1--MinionPro-Regular
otftotfm -a -e texnansx MinionPro-It.otf \
-fkern -fliga LY1--MinionPro-It
otftotfm -a -e texnansx MinionPro-Semibold.otf \
-fkern -fliga LY1--MinionPro-Semibold
otftotfm -a -e texnansx MinionPro-SemiboldIt.otf \
-fkern -fliga LY1--MinionPro-SemiboldIt
otftotfm -a -e texnansx MinionPro-Bold.otf \
-fkern -fliga LY1--MinionPro-Bold
otftotfm -a -e texnansx MinionPro-BoldIt.otf \
-fkern -fliga LY1--MinionPro-BoldIt
The small-caps fonts are generated with an additional "-fsmcp" option. We append "--fsmcp" to the font metric names as well, differentiating them from the regular fonts. Although MinionPro's italic fonts support small-caps, the LaTeX font selection scheme can't access them easily, so we've left them off.
otftotfm -a -e texnansx MinionPro-Regular.otf \
-fkern -fliga -fsmcp LY1--MinionPro-Regular--fsmcp
otftotfm -a -e texnansx MinionPro-Semibold.otf \
-fkern -fliga -fsmcp LY1--MinionPro-Semibold--fsmcp
otftotfm -a -e texnansx MinionPro-Bold.otf \
-fkern -fliga -fsmcp LY1--MinionPro-Bold--fsmcp
To get old-style numerals, just add the "-fonum" option to each invocation -- and, to reduce confusion, append "--fonum" to the font metric names.
At this point, all our font metric files are installed, and it's finally time to create the ".fd" file. (The ".fd" format is documented in The LaTeX Companion.) Let's call the LaTeX font family "MinionPro". Then the ".fd" file is "LY1MinionPro.fd", and it contains:
\DeclareFontFamily{LY1}{MinionPro}{}
\DeclareFontShape{LY1}{MinionPro}{m}{n}%
{ <-> LY1--MinionPro-Regular }{}
\DeclareFontShape{LY1}{MinionPro}{m}{it}{ <-> LY1--MinionPro-It }{}
\DeclareFontShape{LY1}{MinionPro}{m}{sc}%
{ <-> LY1--MinionPro-Regular--fsmcp }{}
\DeclareFontShape{LY1}{MinionPro}{sb}{n}%
{ <-> LY1--MinionPro-Semibold }{}
\DeclareFontShape{LY1}{MinionPro}{sb}{it}%
{ <-> LY1--MinionPro-SemiboldIt }{}
\DeclareFontShape{LY1}{MinionPro}{sb}{sc}%
{ <-> LY1--MinionPro-Semibold--fsmcp }{}
\DeclareFontShape{LY1}{MinionPro}{b}{n}{ <-> LY1--MinionPro-Bold }{}
\DeclareFontShape{LY1}{MinionPro}{b}{it}%
{ <-> LY1--MinionPro-BoldIt }{}
\DeclareFontShape{LY1}{MinionPro}{b}{sc}%
{ <-> LY1--MinionPro-Bold--fsmcp }{}
\DeclareFontShape{LY1}{MinionPro}{bx}{n}%
{ <-> ssub * MinionPro/b/n }{}
\DeclareFontShape{LY1}{MinionPro}{bx}{it}%
{ <-> ssub * MinionPro/b/it }{}
\DeclareFontShape{LY1}{MinionPro}{bx}{sc}%
{ <-> ssub * MinionPro/b/sc }{}
We're now ready to use MinionPro in LaTeX, with lines like this in the document preamble:
\usepackage[LY1]{fontenc}
\renewcommand{\rmdefault}{MinionPro}
\renewcommand{\bfdefault}{b}
Of course, we're free at any time to add more MinionPro variants with otftotfm; they'll become accessible to LaTeX as soon as we edit the "MinionPro.fd" file.
With long options, you need type only as many characters as will make the option unique.
In the command line below, the '<Number>' pattern will force the "onum" feature to substitute only numbers (and not, for example, punctuation). The "salt" feature can still substitute any character.
otftotfm -fsalt --include-subs="<Number>" -fonum ...
If you provide skewchar, a number between 0 and 255 or a single character, then otftotfm adds heuristically-derived kerns to the font that may improve accent positions in math mode. To get the benefits, you must tell TeX about the skewchar with a command like "\skewchar\font=skewchar".
The --altselector-char mechanism uses the features specified by --altselector-feature options.
The alternate-selector character may also be specified in the encoding; see ENCODINGS, below. See Sivan Toledo's article cited in the SEE ALSO section for more information.
OpenType fonts can have many alternates per character, most of which aren't interesting. For example, the character "a" in WarnockPro-Regular has five alternates, "ordfeminine", "Asmall", "asuperior", "a.end", and "orn.013". The --altselector-char option lets you cycle through these alternates, but it's better to leave out the ones you don't want, to avoid overfull encodings. Thus, if you were only interested in ".end" variants, you might supply an '--include-alternates="*.end"' option.
In the command line below, the '*.end' pattern will apply to "aalt" alternates, but not to "salt" alternates.
otftotfm -fsalt --include-alternates="*.end" -faalt ...
WarnoProReg--eka eka
WarnoProReg--exp1 exp1
The named fonts must have been created by prior runs of otftotfm on
the same input OpenType font, with the same --extend and
--slant options as the current run. The current output font will
refer to glyphs from the named base fonts when possible. If the base fonts
cover all glyphs required by the output font, otftotfm won't
generate any new base fonts at all. The file can also refer to
dotless-J fonts using the following syntax:
WarnoProReg--lcdfj - dotlessj
In automatic mode, TeX and friends will generally find required font files independently of the vendor you select.
Otftotfm interprets encoding files as Unicode. For example, say an input encoding has "/dotlessi" at position 10. Otftotfm detects that position 10 should contain Unicode character U+0131 LATIN SMALL LETTER DOTLESS I, and uses the font's glyph for that character (possibly modified by any active features). The selected glyph might not be named "dotlessi"; only the Unicode value matters.
Otftotfm assigns Unicode values to glyph names using a table published by Adobe (SEE ALSO has a reference), with extensions for TeX. For more fine-grained control, add UNICODING commands to the input encoding file. These commands have the following format:
% UNICODING glyph =: choice1 [choice2 ...] ;This tells otftotfm that the glyph named glyph translates into the first Unicode value in the choice list that has a character in the font. Glyph and the choices are PostScript glyph names; the initial "%" sign is required; and each UNICODING line can contain multiple commands, separated by spaced semicolons. For example,
% UNICODING pi1 =: uni03D6 ;encodes the character "/pi1" as U+03D6 GREEK PI SYMBOL, and
% UNICODING Delta =: uni0394 uni2206 ;makes U+0394 GREEK CAPITAL LETTER DELTA preferred to U+2206 INCREMENT as an encoding for "/Delta". You can also supply glyph names:
% UNICODING Delta =: Deltagreek Delta ;A mapping with no Unicode values removes that glyph from the input encoding. For instance, this erases any f-ligature characters from the encoding:
% UNICODING ff =: ; fi =: ; fl =: ; ffi =: ; ffl =: ;The slots are available for otftfm's own use, for example for other characters required by the font. (If the f-ligatures themselves are required by the font, for instance by a 'liga' feature, then they will be stored into their old slots when possible.) Map a glyph to 'emptyslot' if you don't want otftotfm to use the slot. For example, this will leave the 'ff' slot unused if the font has no 'ff' glyph:
% UNICODING ff =: ff emptyslot ;(Note that most OpenType fonts provide a visible representation for unused encoding slots, namely a box with an X inside.)
LIGKERN comments in the encoding can add ligatures and inhibit kerns, as in afm2tfm(1). To add a ligature, say:
% LIGKERN glyph1 glyph2 =: result ;The "=:" operator indicates a normal ligature, where both the input glyphs are removed and replaced by result. To preserve the left-hand glyph, for an effect like "glyph1 glyph2 =: glyph1 result", use "|=:" instead; to preserve the right-hand glyph, use "=:|". To remove all kerns between two characters, say:
% LIGKERN glyph1 {} glyph2 ;
A "*" matches any character, so
% LIGKERN a {} * ;
removes all kerns with "a" as the left-hand character, and
% LIGKERN * {} * ;
removes all kerns.
Otftotfm also supports extended syntax for setting kern values and inhibiting ligatures. To add an n-unit kern between two glyphs, say:
% LIGKERNX glyph1 {n} glyph2 ;
where n is an integer. This:
% LIGKERNX glyph1 {L} glyph2 ;
inhibits any ligature between glyph1 and glyph2. "{LK}"
and "{KL}" inhibit both ligatures and kerns.
You can set the --boundary-char and --altselector-char from an encoding file with commands like this:
% LIGKERN || = boundarychar ;
% LIGKERNX ^^ = altselectorchar ;
As with UNICODING, each LIGKERN or LIGKERNX line can contain multiple commands,
separated by spaced semicolons.
Otftotfm has a default set of eight ligatures, namely:
space l =: lslash ; space L =: Lslash ;
question quoteleft =: questiondown ; exclam quoteleft =: exclamdown ;
hyphen hyphen =: endash ; endash hyphen =: emdash ;
quoteleft quoteleft =: quotedblleft ;
quoteright quoteright =: quotedblright
LIGKERN commands in the encoding file and --ligkern options can override
these defaults, or supply the --no-default-ligkern option to turn them
off.
The POSITION command shifts a glyph within its bounding box. The syntax is
% POSITION glyph pdx pdy adx ;This will add pdx units of space to glyph's left edge; raise it up by pdy units; and add adx units to its width. For example, to add 10 units of space to either side of the "T" glyph, supply
% POSITION T 10 0 20To move the "degree" symbol up by 20 units, supply
% POSITION degree 0 20 0
The CODINGSCHEME command specifies the coding scheme for fonts using this encoding. This is a string, less than 40 characters long and containing no parentheses, that classifies the encoding for TeX's purposes. Sample coding schemes include "TEX TEXT", "TEX MATH ITALIC", and "EXTENDED TEX FONT ENCODING - LATIN". For example:
% CODINGSCHEME EXTENDED TEX FONT ENCODING - LATINMost tools ignore the coding scheme; fontinst is an exception. Otftotfm uses the encoding's PostScript name for the default coding scheme.
Finally, the WARNMISSING command makes any glyphs not supported by the input font appear as black boxes. The dvips(1) processor will also print a warning when encountering these glyphs. For example:
% WARNMISSING yes
The --unicoding, --ligkern, --position, --coding-scheme, and --warn-missing options add UNICODING, LIGKERN/LIGKERNX, POSITION, CODINGSCHEME, and WARNMISSING commands to an encoding, and can override commands in the encoding itself. Some common encoding files have commands that are inappropriate for OpenType fonts; for example, "t1.enc" hard-codes f-ligatures, which can cause problems with small-cap fonts. Supply the --no-encoding-commands option to ignore all commands from the encoding file. Commands from options like --ligkern are processed in any case.
New glyphs, such as ligatures and contextual substitutions, are added to the encoding in any empty spaces, using their original locations when possible. If the encoding doesn't have enough space for all new glyphs, shorter ligatures composed of unaccented letters get precedence.
Otftotfm can synthesize some glyphs using virtual font manipulations, if a required glyph is not available in the input font. Specifically, it will synthesize:
The --include-subs and --include-alternates options, and their --exclude and --*-filter variants, accept the following types of pattern.
The "!" prefix negates a pattern, and you can separate multiple patterns by spaces.
This section lists features common to Western OpenType fonts and describes how otftotfm handles them for common fonts. Please send the author mail if otftotfm does not handle a feature you need, or you believe it handles some feature incorrectly.
See the documentation for --pl above if you have problems running otftotfm's output through fontinst.
pltotf(1), tftopl(1), vptovf(1), afm2tfm(1), dvips(1), cfftot1(1), otfinfo(1), t1dotlessj(1), t1testpage(1), ttftotype42(1), kpsewhich(1), updmap(1)
Adobe Type 1 Font Format
Adobe Technical Notes #5176, The Compact Font Format Specification, and #5177, The Type 2 Charstring Format
OpenType Specification, Version 1.4
A Directory Structure for TeX Files, http://www.tug.org/tds/
Kpathsea: A library for path searching, http://www.tug.org/kpathsea/
Sivan Toledo, Exploiting Rich Fonts, TUGboat 21(2), 2000, http://www.tug.org/TUGboat/Articles/tb21-2/tb67tole.pdf
Michel Goossens, Frank Mittelbach, and Alexander Samarin, The LaTeX Companion (for information on the .fd file format)
Adobe Systems, "Unicode and Glyph Names". Refers to the glyphlist.txt file used to translate glyph names to Unicode code points. http://partners.adobe.com/public/developer/opentype/index_glyph.html
Eddie Kohler (ekohler@gmail.com)
Thanks to Karl Berry, Marco Kuhlmann, Adam Lindsay, Bruce D'Arcus, Thomas Esser, Claire Connelly, Nelson H.F. Beebe, and Ryuji Suzuki for suggestions, bug reports, and help. Particular thanks to Achim Blumensath and Michael Zedler for suggestions and patches, some of them extensive.
| LCDF Typetools | Version 2.110 |