Is there a reference list for the encoding of fonts in LaTeX? A place where one can search for a specific font and get the relevant code that represents it. Some of them are not even logical, for example, for TeX Gyre Heros I would imagine a code like "tgh
", but the code is "qhv
":
{\usefont{T1}{qhv}{b}{n}\selectfont\huge} %"qhv" - TeX Gyre Heros, "b" - bold
{\usefont{T2A}{qcr}{m}{n}qcr\selectfont} % Another font
I was searching for the equivalent family code for Alegreya and Alegreya Sans but I can't find it. It must exist, me thinks, because my logic tells me every font in the world has a code like this associated to it? Or maybe not? Where would one search for such a code? I also opened the font in my font viewer with no success.
Cheers!
Best Answer
A more general way of finding the family name which does not require you to open files and does not depend on the existence of a
.sty
file, is to use the names of the font definition files (.fd
). This will work with any font which is set up for use with LaTeX, regardless of whether a.sty
file is supplied or not.Suppose you would like to use Zapf Chancery. This is supplied by the
zapfchan
package, and is included in standard TeX distributions. Examining the contents oftexmf-dist/tex/latex/zapfchan/
(TeX Live):There is no
.sty
file in this case. This makes it even more important to be able to figure out the family name since it is the only way of using the font with LaTeX.It helps to know a little bit about font encodings at this point.
8r
,oml
,oms
,ot1
,t1
andts1
are lower-case versions of different font encodings used by TeX: 8r, OML, OMS, OT1, T1 and TS1. To figure out the family name, it doesn't matter what these are. All that matters is that you know they are encodings..fd
file. -> E.g.t1uzc.fd
..fd
suffix. -> E.g.t1uzc
.uzc
.uzc
.Some fonts may have several different font families, in addition to different encodings. In these cases, you would need to investigate further to figure out which family you wanted to use. For Zapf Chancery, however, there is just the single family
uzc
and that is what you would use to select the font in LaTeX.The name of the font definition files tell you one other crucial thing: they tell you which encodings the font is available in. In this case, you have:
You might be puzzled at this point to find that
still produces Computer Modern Roman rather than Zapf Chancery. LaTeX will be warning you that it has substituted fonts on the console and in the log and (for pdfTeX) your PDF viewer will show you CMR is still being used. Why does the font selection fail?
To figure this out, you have to look inside the font definition file. (I only said you didn't have to open files to figure out the family - I didn't say you'd be able to use it!)
Reading
t1uzc.fd
, we find the following line:This shows that the family includes a font in the series
mb
(medium bold) and shapeit
(italic).The next two shape declarations:
tell us that this single font (
uzc/mb/it
) is silently substituted (i.e. without warning) if the italic shape in medium weight is requested (m
series) or the slanting shape (sl
) in the medium bold series.The final shape declaration:
tells us that the
uzc/mb/sl
is silently substituted if the slanting shape in the medium series is requested. Since the italic, medium bold is substituted foruzc/mb/sl
anyway, this effectively means that no matter which of italic and slanting are requested, and no matter which of medium and medium bold, we will always get the italic, medium bold shape.However, nothing is defined for the standard, upright shape. So to actually use Zapf Chancery, we need to also change to the italic or slanting shape. To be on the safe side, it would be best to specify the weight, too. That way, if bold is active, say, we won't get something unexpected (such as CMR in bold).
Note that this method of finding the family name will work whether or not the font name follows the Berry scheme. For example,
tells us that there is a font family available in the T1 encoding named
EBGaramond-OsF
which we could similarly select with\fontfamily{}
if appropriate. [Although it would generally be better, in this case, to use the.sty
file provided by the package.)