I am curious to know which font extensions works better when using XeLaTeX to compile a TeX document. I have just downloaded the font Alegreya from CPAN, and it comes with a fonts folder that includes folders with the font in several formats:

afm       *.afm
enc       *.enc
map       just one file: Alegreya.map
pfm       *.pfm
tfm       *.tfm
truetype  *.ttf
type1     *.pfb
vf        *.vf

I know nothing about fonts and I didn't even know there were so many font formats out there in the wild, I have no idea what are they used for.

I tried type1 and truetype formats in my TeX document by adding:

\setmainfont[   Path              = ./alegreya/fonts/truetype/huerta/alegreya/,
                Extension         = .ttf,
                BoldFont          = Alegreya-Bold,
                ItalicFont        = Alegreya-Italic,
                BoldItalicFont    = Alegreya-BoldItalic,
                SmallCapsFont     = AlegreyaSC-Regular,
                SmallCapsFeatures = {Letters = SmallCaps},
                Numbers           = OldStyle

to the preamble of my document (same for type1 using Path = ./alegreya/fonts/truetype/huerta/alegreya/ and Extension = .pfb). Both formats work in the sense that I don't get any compilation errors and the PDF looks fine.

My question is: is there a preferred font to work with XeLaTeX that I should be using? What's the best practice regarding font embedding, if there is any? What should I use, ttf, pfb or other?


  • 1
    You should use the .ttf here. Even better would be .otf but you do not have this for your font. You may read a bit about fonts and about the different file-extensions. I guess that most of the named above are not even fonts but mappings, encodings, vectorgraphics and alike. Just guessing. – LaRiFaRi Sep 22 '14 at 13:00
  • 1
    related: tex.stackexchange.com/q/119467 – LaRiFaRi Sep 22 '14 at 13:21
  • 1
    Off-topic: There is no need to install this font yourself. It is part of standard TeX installations and may certainly be installed using the package manager if you do not in fact have it already. – cfr Sep 22 '14 at 14:21
  • @cfr Thanks cfr. I think I don't have Alegreya installed by default in my texlive installation, since I can't find it in my fonts path (which I think is /usr/share/texlive/texmf-dist/fonts/ in my case). Anyway, I prefer to use the font from the folder where I am creating the tex document, since I would like to share it with more people who could edit it even if, like me, they don't have the font installed in their system neither. Cheers! – Xirux Nefer Sep 22 '14 at 14:36

First let's have a look on all the files. Here is, what I guess they are (but I am no expert here...). Please also have a look on Mrs. Beeton's comment below which discusses some of my misinterpretations and gives more information on certain extensions:

  • afm: Adobe font metrics file
  • enc: Encoding file
  • map: mapping which tells TeX how .tfm fonts relate to actual type1/truetype/metafont fonts
  • pfm: Printer outline metric font file
  • tfm: TeX Font Metric file
  • ttf: TrueType Font file
  • pfb: Type 1 PostScript font file (binary)
  • vf: TeX virtual font file

The question on .ttf vs. T1 is treated here and for sure somewhere on this site as well.

.vf files are roughly TeX font metric files for 'virtual' fonts. These may be composed from characters taken from different fonts. For example, you could create a font including oldstyle figures using letters from a regular font and figures from a supplementary font. They may also tell TeX how to construct characters not present in the original font, including ligatures (e.g. ffi) and accented characters (e.g. é). Like .tfm files, they also include metric information needed for bounding boxes, italic correction, the use of ligatures (e.g. f + i -> fi) etc. Please see here for very good information on this topic.

Finally as a clear answer to your question: You should use the .ttf file here. As XeLaTeX is able to handle these fonts, you should use it. Even better would be .otf, but I do not want to open a redundant font discussion here.

  • Thank you @LaRiFaRi. Very interesting links, specially the second one. I had heard that vector fonts are best, since they can be scaled without losing detail, I guess that's why .otf is better as it combines vector and TrueType?. Since my font doesn't have an .otf version, I'll follow your advice and use the .ttf instead. – Xirux Nefer Sep 22 '14 at 13:31
  • 5
    .tfm is more likely "tex font metric file". i have yet to see this abbreviation used for anything else. also, regarding .vf files, it's possible to use these to "rearrange" the locations of glyphs in a font, and also to construct composites (say, preaccented letters) to provide glyphs that aren't natively in a font. since this appears to be a "tex-able" font package, i think also that the .map may be a directive for use with certain tex device drivers, to associate an "internal" name with the system name of a font. – barbara beeton Sep 22 '14 at 13:36
  • 1
    pfb is PostScript font (binary) in difference to pfa (ascii) – user2478 Sep 22 '14 at 14:06
  • 1
    In addition to what @barbarabeeton says, .vf files can also tell TeX how to construct glyphs and ligatures lacked by the font - not just accented characters but also things such as ffi. To use this font with TeX (rather than XeTeX), you would need the .enc, .map, .tfm, .pfb and .vf. You would also probably use this for pdfTeX, although pdfTeX can use .ttf files in place of .pfb. .pfb files are not complete fonts. They include the glyphs but not the font metrics which includes kerning information. These are usually supplied in .afm files from which you can create .tfms. – cfr Sep 22 '14 at 14:10
  • The definitions can be found under section 3.2 "Fonts" in tug.org/tds/tds.pdf – Ioannis Filippidis Jan 15 '16 at 4:49

In principle, XeTeX works fine with .otf or .ttf font files. However, in some cases the .ttf version of a font lacks some metadata (for compatibility with older versions of Windows), so when both are available you should prefer the .otf.

An older font format was Type 1, which consists of a pair of a data file .pfa or .pfb and a metrics file .afm. While XeTeX has some support for Type 1 fonts, you will most likely find it deficient (no automatic support for character variants, no support for the seac operator); avoid the Type 1 format with XeTeX whenever possible.

The other types of files are of no interest to XeTeX. (.pfm files are just .afm files converted to a Windows-specific binary format. .enc, .map, .tfm, .vf are support files for traditional TeX/pdfTeX.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.