I've heard that PDFTeX can use TrueType fonts. There have been several answers related to this, but of these only the first one mentions using otftotfm, which I'm told is the standard way to do it now, and none clearly explain how to use the font if your document after it has been created.
The otftofm documentation just uses \renewcommand{\rmdefault}{MinionPro}
, which looks simple enough, but I thought that LaTeX used 4 letter names, something like {\fontfamily{antt}\selectfont Foobarbaz}
, not human-readable names.
There is what looks like a pretty good manual for otftoftm, but it is very focused on otf fonts, so I'm not sure what features I should use with TTF fonts.
There is also a package on CTAN for this, but it seems to require Ruby, which I don't currently have (but can get if this is indeed the best way).
Also, how do I use multiple TTF files together. For example if I wanted to use Times New Roman as it comes with Windows (For example, I know there are times
packages), it has Times New Roman Bold, Times New Roman Bold Italic, Times New Roman Italic and Times New Roman Regular.
So can someone either guide me to complete documentation on how to put this all together, and how to then use it in the LaTeX document, or write one?
Edit; I've been asked why not to just use the TrueType font directly without otftofm. I mainly specified the tool to make this distinct from the other questions: If there is an easier way I will accept it as well.
Best Answer
Ok, so here it comes.
I should declare that
otftotfm
for every combination of font family, encoding, and typeface. Apart from that, the script just configures some project-specific paths and automates the total bunch of calls to install every font for a project in one run.Furthermore, if you've read the
otftotfm
manual, there isn't really much more I can say. So I'll just report about some step-by-step experiments I did with plain vanillaotftotfm
and somettf
fonts I found on my Linux box, going strictly by the manual.Calling
otftotfm
First of all,
otftotfm
is really meant for installing.otf
fonts for use with LaTeX. Depending on the font format "hidden" in the OTF, it will write a.ttf
or a.pfb
. All this happens behind the scenes. It is all ironed out in the map file which is also updated automatically.As you explicitly asked for
.ttf
, this is what I'll be referring to in the following. The usage and all the further steps are completely identical for.otf
files. In fact,otftotfm
doesn't really distinguish between.otf
and (well-behaved).ttf
apart from giving a warning about TTF support being "experimental" and sometimes failing for non-well-behaved TTF. I never had a failure with OTF.As documented, to install the font
Ubuntu-R.ttf
in automatic mode, the following call is sufficient:The
-a
stands for automatic mode, meaning all derived files will be automatically put in the right places.-e ec
says which encoding to use.ec
is the normalT1
encoding, but you can also usetexnansx
as proposed in the manual. Probably those characters inec
which are not intexnansx
won't be found in most non-TeX fonts anyway.-fkern -fliga
activate the otf features "pair kerns" and "f-ligatures" which is something one would always want for TeX. There's a long list of other supported features, but I don't know what they are.Ubuntu-R.ttf
is just the file name of the font I found.T1--Ubuntu--Regular
is the "TeX name" I chose for the font; we'll need that later on.Now is a good time to take a look at the log file. I'll just copy some lines which are interesting (it's rather long because of the
--verbose
option):In principle this means all is well. We also get some info on the paths used.
The only thing which is slightly undesirable is that
lcdftools
(which is the vendor name ofotftotfm
) is used as the default vendor name of the font.otftotfm
could really have taken this out of the font info (as it does for the font name)!So I use
yielding (among other things)
So now I can give an explicit vendor name to
otftotfm
(note that this is not at all neccessary for things to work, it's just more orderly).In the same manner, I install the further members of this family:
Now, the most complicated part is already over. All the neccessary internal files are in place.
Just for the fun of it, I also install a couple of "decorative" fonts I found lying around in the Linux box. Each represents a single typeface, so they don't form or participate in a family.
But what's that? Some of the fonts installed are OTF fonts???
The reason is that the original try to install the ttf failed.
When calling
I got in the log file the lines
and, what's more important, no message about updating the map file at the end!
Unfortunately, I didn't find a better indication that installation did not work. In fact,
tfm
andvf
files were produced, but withoutmap
entry,pdftex
can not directly use the font.At this point, you basically have two options:
ttf2afm
.fontforge
and save asotf
.As I don't know anything about 1., I chose 2. There are some issues with this, as the font is converted from TTF to TYPE1, they have different spline models, yadda yadda. So the glyphs may change, and indeed
fontforge
is complaining about intersecting paths and suchlike. But I never ever have seen a difference, and I wouldn't even know where to look (in commercial projects, this practically never happens, and if it does, we just tell the customer to buy an OTF version; fonts are not that expensive).So I have converted some of the fonts to OTF. These fonts are far from "print production" quality, anyway!
fontforge
is a free font editor which used to be calledfontedit
IIRC. Among other things, it can be used to convert font formats.After this, installing with
otftotfm
works for sure..fd
filesThe only thing not automatically generated by
otftotfm
is anfd
file declaring the typefaces of a family to LaTeX.For the single typefaces, this is easy: Just declare what typeface we have.
goes into a file
t1baileyscar.fd
. Here we are declaring a font familyBaileysCar
consisting of a single typeface medium / normal. The font nameT1--BaileysCar--Regular
is just the "TeX name" I chose when installing the font. Note that the file name has to be exactlyt1baileyscar.fd
, consisting of the "LaTeX encoding name" (which is T1 forec
encoding) and the family name in lower case! LaTeX will construct this name when looking for the declaration of a given font family in a given encoding.For
Ubuntu
which is a real family consisting of several typefaces it is preferable to make a largerfd
file declaring a larger range of font shapes. The following filet1ubuntu.fd
was adapted from another.fd
file I found on my system (take for instancet1ptm.fd
).In addition to the typefaces I actually have, I'm also declaring substitutions for shapes which are not there. The declaration
means when looking for a "medium small caps" typeface, "medium normal" should be used.
The documentation for
.fd
files is in fntguide.Example of Use
To demonstrate all the fonts, I made the following example file:
Those lines referring to our font installation are
These refer to the generated
.map
files. You can look up that info in the log file, but it is really <vendorname>.map
.Furthermore, I need to refer to the names of the font families with
\fontfamily
. Redefining\rmdefault
just changes the default roman font family for the whole document.The result looks like this:
In the leftmost column, you can see that the new "Ubuntu" family works a s expected with different typefaces.
To show all the nice new decorative fonts in a little more detail:
Conclusion
So, basically, the process of using a new TTF font with LaTeX boils down to (if you want the easiest possible usage)
copying the command line
into a command shell, replacing
myfont
by the name of your font.copying the lines
into a file
t1myfontlc.fd
, replacingmyfont
by the name of your font andmyfontlc
by the name of your font in lower case.Adding the line
\pdfmapfile{lcdftools.map}
to the preamble of your document.Using
\fontfamily{myfont}\selectfont
to use the new font in the document.I can't imagine how this could get any easier considering the task at hand ;-)
I'm not sure this "explanation" is any more helpful than the other ones, but I think font installation is much less scary nowadays than it used to be ;-)
If there are any remaining questions, please ask.