Archive for the 'LaTeX' Category

OpenType-Fonts in Texlive/Xetex

Tuesday, October 19th, 2010

This is a follow-up to my rant TrueType- and Type1-Fonts in Texlive/Xetex.

As it turns out, XeLaTeX is not only the solution to displaying TrueType and Type1-Fonts, but most of all, the solution to display (and print, of course) OpenType. And not just with basic support, but with everything only OpenType makes possible. Like decent handling of ligatures.


\documentclass{article}
\usepackage{fontspec,xunicode,xltxtra}
\setmainfont{Baskerville}
\begin{document}
\section{Font Tests}
\fontspec[Ligatures={Common, Rare}]{Baskerville}
\fontsize{18pt}{24pt}\selectfont Baskerville \\
Umlauts: ÀöÌ \\
Ligatures: ct st fi fj fl ff ffi ffl fs ft ij \AE \ae \OE \oe\\
\fontspec{Baskerville}Numerals: 1234567890\\
\fontspec[Numbers={OldStyle}]{Baskerville}Numerals Old: 1234567890\\
\\
\end{document}

“Baskerville” in that example is any OpenType-font which provides ligatures (liga) old numerals (onum), required ligatures (rlig) and so on..

TrueType- and Type1-Fonts in Texlive/Xetex

Tuesday, November 10th, 2009

Font-Management in TeX is a huge mess. It’s such a mess that there is not even one coherent tutorial on how to install fonts exists, and nobody ever automated it. Imagine: You put your TrueType or Type1 fonts somewhere into /usr/share/fonts, your system regenerates its font-cache, and they not only are available for KDE, Gnome, Mozilla and OpenOffice, but also for TeX? You wish. Instead you’re expected to produce custom font-encoding files by hand, extract font-metric-files (tfm) out of TrueType-files, invent 6-letter font-shortcut-names, and edit some other files in order that TeX can find them with these shortcut-names. In other words, the whole thing should be burned at the stake, shredded, buried and shot into outer space.

The only thing that actually works out of the Box is XeTeX/XeLaTeX:

apt-get install texlive-xetex

Now you need to know the correct name of the font you want to use, as reported by fc-list:

$ fc-list | grep Bastarda
MA Bastarda1 15th:style=Normal

And you can use this in TeX-documents:

\documentclass{article}
\usepackage{fontspec,xunicode,xltxtra}
\setmainfont{MA Bastarda1 15th}
\begin{document}
Test. Umlauts need to be UTF-8 encoded: ÀöÌ
\end{document}

If your TeX-document happens to use utf8mb4 instead of utf8, recode will help:

recode utf8mb4..utf8 whetever.tex

Now you need to use xelatex instead of texi2pdf or pdflatex to produce a pdf-file:

$ xelatex whatever.tex

That’s it, and that’s how it should bloody work everywhere, with every TeX-util of the day you might want to use.