# Using scalable fonts with LaTeX

I have a .mf file which describes the glyphs in the font. Using `mftrace`, I understand how to get the Adobe font metric information (.afm file) and Type1 fonts (.pfb file) from the .mf file.

How does one use scalable fonts with LaTeX so that it renders well in most devices and also print ? (some sources tell to avoid TeX-bitmap fonts to create documents for web-publishing)

• What kind of font? Can you use the `.mf` version already? That is, is the issue just how to enable the type1 version, given that the source version works? If so, you should already have at least one TFM file and you should be able to use the type1 PFB as a 'drop-in' replacement. If not, things are more complicated as you need to create one or more TFM. The AFM gives part of the information you need for this, but not all of it. Does the font match a standard TeX font encoding?
– cfr
Apr 7, 2016 at 22:05
• Note that the process for enabling a new font with traditional TeX engines is quite involved and you will need to consider how much effort you are prepared to put in. (That is, if the PFB is not just a 'drop-in' for an already supported font.) Typically, moreover, this will support the use of the font in PDF. I won't support the use of the font on the web if that means HTML as opposed to PDF.
– cfr
Apr 7, 2016 at 22:08

This question cannot be answered as it stands. This answer aims to provide an overview of some of the factors which must be considered when installing TeX fonts.

The easiest way to use an arbitrary font is to use LuaTeX or XeTeX as your compiler and to load the `fontspec` package. This is ideal for opentype or truetype fonts.

I'm assuming that you want to use TeX or pdfTeX and so need to use traditional TeX fonts.

There is no one answer to the question you ask. It depends on the font and on the purpose to which you want to put it. There is a great deal of difference between installing a font containing a single symbol and a font designed to typeset text with multiple ligatures, kerning pairs etc. Or, again, a font designed for mathematics.

At a minimum, the following are required:

1. the PFB font which contains the instructions for drawing the picture of each character (glyph);
2. one or more TFMs - TeX Font Metric files - which provide information about the size of the box containing each character, how to adjust the positioning of certain sequences of characters (kerning pairs, possibly ligatures);
3. one or more lines for the MAP file, typically in the form of a `.map` file fragment;
4. one or more font definition files (`.fd`) which tell LaTeX when to use the font [this information can be given in a `.sty` file or in the `.tex` document, but it is more convenient to use an `.fd`).

1. one or more encoding files (`.enc`);
2. one or more virtual fonts (`.vf`) [only strictly needed if you are combining characters from different fonts or if you need to fake certain characters or shapes, but they can be convenient in other cases, too].

In order to create a TFM for the font, you need the AFM.

Crucial questions:

1. What encoding do you wish to use? Compare the characters the font provides - or the subset you wish to use - with the character tables for standard encodings. For example, `T1`, `OT1` etc. If the font is a symbol font - where this means something like ding bats rather than maths symbols - then you can skip this and use the font's own encoding. In this case, you install an unencoded/raw font (`U`). In all other cases, you need to find a good match in a standard encoding.
2. Is one TeX font sufficient? A text font cannot contain more than 256 characters and some of the available slots are needed for various mechanical/technical purposes. It is perfectly possible to use all of the characters from a much larger PFB. However, in that case, you must present TeX with several TFMs, all of which may be based on the single PFB. That is, one type1 font can make several TeX fonts.
• A symbol font containing more than 256 characters must be similarly split when creating TeX fonts, so the mere fact that you could use `U` does not necessarily mean that you want to.
3. How are the characters named? Do their names match the names in the `.etx` or `.enc` or whatever files which you will use to define your encoding(s).

Depending on the answers to these questions, you may use tools such as `afm2pl`, `fontinst` etc. to create the TeX fonts. In the simplest cases, this may take 5 minutes. In the most complex cases, it may take considerably longer.

So it is vital to begin by evaluating what you are dealing with and exactly what you want to achieve in terms of functionality in TeX.

As far as I know the afm files are not necessary for TeX.

For to install the type 1 font in a personal directory, move your pfb files to `\$TEXMFHOME/fonts/type1/public/mypackage/` and the tfm files to `\$TEXMFHOME/fonts/tfm/public/mypackage/` (cf description of the TeX directory structure).

You also have to create a map file called `mypackage.map` with one line for every font. In the simplest case of one single font you have to type `myfont myfont <myfont.pfb` where `myfont` is the TeX font name. Move this file to `\$TEXMFHOME/fonts/map/dvips/mypackage/`. Then create the file `\$TEXMFHOME/web2c/updmap.cfg` if it doesn't already exist and add the line `Map mypackage.map` to this file.

Run `updmap` on the command line and the type 1 font should work.

• Don't do this! Never, ever run `updmap` or install fonts into TEXMFHOME unless (1) you have no choice and (2) you understand and accept the consequences. This way madness lies. Even if both (1) and (2) are true, I would very strongly recommend not doing this. In the vast majority of cases, it is far easier to do without a font. (Nutty thesis rules may be the single exception.) In any case, in the vast majority of cases, what you've described is not enough and will not make the font usable. TeX doesn't use AFM files but it needs TFM files which are typically created from AFMs and more.
– cfr
Apr 7, 2016 at 21:59
• Please read my question and answer on why you shouldn't use `updmap` and how to recover if you read it too late. (The issue with `getnonfreefonts` and with `updmap` is the same hence I cover them together.) I don't know about MikTeX but for TeX Live, use of `updmap` is a common source of mysterious failures and output weirdnesses.
– cfr
Apr 7, 2016 at 22:02
• Please consider deleting or correcting this answer. It is very, very, very bad advice. Really, people should not do this and recommending they do is deeply problematic.
– cfr
Oct 5, 2016 at 0:31