otftotfm (1) Linux Manual Page
NAME
otftotfm – create TeX font metrics from OpenType fonts
SYNOPSIS
otftotfm [-a] [options] fontfile [texname]
DESCRIPTION
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:
ont\myfont=texname at 10pt
{\myfont This text uses the OpenType font.}
LaTeX users will generally make a ".fd" input file so that commands like "
enewcommand{
mdefault}{TeXName}" work correctly. See the EXAMPLE section for more; check the DIAGNOSTICS and FREQUENTLY ASKED QUESTIONS sections if you have trouble.
OpenType Features
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 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
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 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 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 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 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.
EXAMPLE
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 e, 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:
