11

In Xe(La)TeX, what is the difference between loading a font via its package, i. e. \usepackage{tgpagella}, and loading it through fontspec (\fontspec{TeX Gyre Pagella}).

When loaded with the package, are the OTF fonts being used? As the TFMs are included in the package, I wondered whether fontspec might or might not use them, or does fontspec build its own ones? Are there any downsides to using fontspec where a package is available? It seems to me that the package contains TeX-specific information, which might be lost (?) if I just load it through fontspec.

  • 1
    viz you first question, if you do \usepackage{tgpagella} the fonts as prepared especially for TeX are used, not the OTF fonts. – user4686 May 26 '14 at 14:04
  • 3
    But this depends on the package. Some font packages are 'XeTeX aware'. Others are not. – cfr May 27 '14 at 3:09
5

Many TrueType and OpenType fonts have been packaged, chiefly to bring those using latex and pdflatex some of the variety enjoyed by those using xelatex and lualatex. Many, if not all, of the packages can be used with xelatex and lualatex as well as latex and pdflatex, and that’s convenient for anyone who hasn’t yet decided on an engine or who plans to share the source file with others and doesn’t know which engine they use. It’s also convenient for users of xelatex or lualatex who haven’t the time or the inclination to read the fontspec manual or to study the features of a font — but I don’t imagine that very many people fall into that group, because the most obvious attraction of xelatex and lualatex is their handling of fonts.

Not all packages provide options for all features. Fonts like EB Garamond are so rich in features that an adequate discussion would be too long here, so let’s consider a small and relatively simple font, Quattrocento. Its features, as reported by otfinfo, are:

aalt   Access All Alternates
frac   Fractions
kern   Kerning
liga   Standard Ligatures
ordn   Ordinals
salt   Stylistic Alternates
sups   Superscript

The package provides several options, among them rm, sf, sfdefault, and scaling. There is no option for using the superiors, like the footnotefigures option of MinionPro, but that’s probably good because the font has superiors only for 1–3 (if compatibility with pdflatex is unnecessary, you can load realscripts, but expect trouble with more than three footnotes). Also, there’s no option for using the stylistic alternates, which affect M, W, and Q.

Now, it’s possible to get the alternates anyway, like this:

\documentclass{article}
\usepackage{quattrocento}
\begin{document}
My Wee Quokka

\addfontfeatures{Style=Alternate}
My Wee Quokka
\end{document}

output of example

That works because quattrocento.sty loads fontspec when used with xelatex or lualatex. (As cfr noted, not all packages do this.) For the same reason, you can also write \defaultfontfeatures{Style=Alternate} after \usepackage{quattrocento}, but it will have no effect precisely because it’s loaded afterward.

Of course, using \addfontfeatures{...} in your document means losing the advantage of compatibility with other engines. As for the other advantage of the packages, namely, not having to read the fontspec manual and examine the fonts, if you haven’t done those things, you won’t know that these features exist and that you can get them with \addfontfeatures{...}. Personally, I’d rather read the fontspec documentation and examine the fonts I like than spend time reading the documentation for many font packages.

It’s worth noting that some packages are based on Google’s web fonts rather than the originals, and that web fonts are optimized for the web, not for printing. For example, some or all alternates may be removed to speed up the downloading of a web font; in such cases, packages built from the web fonts will also lack the alternates. And sometimes web fonts add artificial italics or bold weights, good enough for the web but not for print.

Even if a packager wants to make every feature of an OpenType font available through package options, some features may be difficult or impossible to implement for pdflatex. An example is randomization; I’m no programmer, but I can’t imagine how that would be done in pdflatex. If the packager doesn’t want to add an option that works only for some engines, users of xelatex or lualatex who assume that the package does whatever can be done will miss out.

So if you’re in a hurry and happen to remember the name of a package but not the fontspec invocation, use the package; but if you use xelatex or lualatex and care about typefaces, either use fontspec or examine the fonts and the package closely before trusting the package to equal the performance of fontspec.

  • I always assumed that the deficiencies in these packages were due to the fact that (pdf)TeX support was seen as the poor relation, all but obsolete and disappearing fast. I didn't appreciate that this applied to the `Xe/LuaTeX side as well. The type1 support is lacking in large part because the support is generated automatically without much (any?) fine-tuning. Is the same true for the Xe/LuaTeX provision as well? I also didn't realise that these used Google fonts and that those were simplified versions of the originals. – cfr Oct 4 '15 at 1:06
  • 1
    I'd add small-caps to the 'not good enough to print', I think. You can get the variations needed for randomisation with traditional fonts, but I don't see how you could randomise it without, say, making all the characters active which would be much too high a price to pay. The main limitation I ran up against again and again is the 256 character limit. I have had to explain to a font designer that I cannot support X and Y simultaneously (without a user switching fonts) for this reason. Extra ligatures, swashes, alternates all need slots ;). – cfr Oct 4 '15 at 2:59
  • @cfr The source of web fonts also makes a difference. E.g., Google’s version of Sorts Mill Goudy omits the real small caps found in the original, whereas the Open Font Library includes them. No rest for the wicked, and none for the font-packager either. – Thérèse Oct 4 '15 at 3:15
8

In an up-to-date TeXLive 2014 there are some font packages which supports all engines: xelatex, lualatex, pdflatex, and latex:

accanthis
Alegreya
cabin
cinzel
ClearSans
ebgaramond
FiraSans
gillius
gillius2
libertine
librebaskerville
librecaslon
LobsterTwo
merriweather
mintspirit
minspirit2
newtxmath
quattrocento
sourcecodepro
sourcesanspro
  • 2
    If a font offers many features, a package may provide access only to its most basic features. For example, ebgaramond allows for choosing between old-style, lining, proportional, tabular, and superior figures, and it defines commands for swashes and decorative initials. However, a user who has studied the font and knows how to turn features on and off through fontspec can control contextual and rare ligatures, choose among variants of a character, etc. – Thérèse May 28 '14 at 10:34
  • The package loads the font with more or less default features. It is left to the user to change or add the features. – user2478 May 28 '14 at 12:06
  • 2
    Those changes or additions are made with fontspec, since the package does not have options for the more “exotic” features. So anyone who wants to take advantage of all of a complex font’s features may as well use fontspec from the start. The packages are mostly for the convenience of those not using xetex or luatex. – Thérèse May 28 '14 at 12:34
  • everything is done via fontspec. But for a user who wants do have for example the libertine with default behaviour, it maybe easier to use \usepackage{libertine} instead of all the \set???font[...]{..} commands. – user2478 May 28 '14 at 13:17
  • @Thérèse If you were to make an answer out of your comments, I would gladly accept that answer. – brian-ammon Oct 3 '15 at 20:22

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.