Posts Tagged ‘fonts’

If you know me at all you know that I love LaTeX.  It let’s you specify the content and logical structure of your document and takes care of making it look nice, including tricky mathematical expressions, yadda yadda yadda.

One thing that LaTeX is really bad at, though, is font support.  This isn’t a problem for the most part, and I’ve actually come to prefer the look of Computer Modern (the only real font ever created using Knuth’s Metafont language, and instantly recognizable to LaTeX geeks the world over).  But if you need to, say, typeset something in Arial (shudder), there isn’t exactly an easy way to do it, and god forbid that you might want to use a font that’s not freely available (like, just an arbitrary example, Times New Roman).

Enter our hero, XeTeX (and it’s big sibling, XeLaTeX).  XeLaTeX extends the low-level typesetting engine of TeX to use modern font/typography technology.  This includes support for Unicode, and super-slick typography conventions like OpenType and Apple Advanced Typography (AAT), which allow the typesetting of scripts with complicated rules for combining symbols (like Tibetan) and different writing directions (e.g. right-to-left scripts such as Arabic and Hebrew).

The really great thing about XeTeX, for my current purposes, is that it allows you to typeset almost anything using any font installed natively on your computer.  That is, XeTeX essentially adds that drop-down font-selection menu that every other text editor has.

As an example, I will show you how stupid-easy it is to typeset a document in 12 pt. Times New Roman (with 1-inch edges, not that it matters)

\setmainfont[Mapping=tex-text]{Times New Roman}

Yes, folks, it really is that easy: just two lines of code (above and beyond the usual documentclass/geometry combo), and nothing whatsoever that needs to be converted using FontForge, etc.  The only trick is that, instead of running latex, you run xelatex (which is easy to automate using emacs and AUCTeX).

As you can probably tell from the snippet above, the package you want to use is fontspec, which is the LaTeX interface for XeTeX’s font-specification system, and its documentation has lots of good examples.