[Tex/LaTex] Using \fontsize in XeLaTeX and LuaLaTeX

fontsfontspecluatextypographyxetex

In the Wikibooks/TeX article on fonts, it is stated that

The \tiny\Huge commands are often enough for most contents. These are fixed sizes however. In most document processors, you can usually choose any size for any font. This is because the characters actually get magnified. If it usually looks correct for medium sizes, it will look odd at extreme sizes because of an unbalanced thickness. In TeX it is possible to change the magnification of anything, but highly discouraged for the aforementioned reason. Changing the font size is made by changing the font file. Yes, there is a file for every size: cmr10 for Computer Modern Roman 10pt, cmr12 for Computer Modern Roman 12pt, etc. This ensure the characters are correctly balanced and remain readable at all defined sizes.

I do not know what exactly they mean by the "unbalanced thickness" (a side question: what is meant by this?). However, if I use fontspec and a system font in either XeLaTeX or LuaLaTeX, there is — as far as I know — no file for every font size. So does fontspec produce worse result for large fonts because of this? And finally, my main question: Is it still discouraged to use \fontsize and arbitrary font sizes when using fontspec?

Best Answer

An example is worth a thousand words; I used Plain TeX for better showing what's going on, with the explicit sizes shown.

\font\testhuge=cmr17 \font\testhugescaled=cmr17 at 10pt
\font\testbig=cmr12  \font\testbigscaled=cmr12 at 10pt
\font\testsmall=cmr7 \font\testsmallscaled=cmr7 at 10pt
\font\testtiny=cmr5  \font\testtinyscaled=cmr5 at 10pt

\offinterlineskip

{\testhuge ABCDE}
\vskip1pt
{\testbig ABCDE}
\vskip1pt
ABCDE
\vskip1pt
{\testsmall ABCDE}
\vskip1pt
{\testtiny ABCDE}

\bigskip

{\testhugescaled ABCDE}
\vskip1pt
{\testbigscaled ABCDE}
\vskip1pt
ABCDE
\vskip1pt
{\testsmallscaled ABCDE}
\vskip1pt
{\testtinyscaled ABCDE}

\bye

Note that in the middle there's the normal size font, cmr10.

enter image description here

In the upper half, the fonts are at their nominal size; apart from the last row, where cmr5 is used, the proportion of black and white is very similar.

In the lower half, the fonts are normalized to 10pt; as you see, the bigger fonts appear lighter and the smaller fonts appear thicker. Moreover, scaling small fonts results in wider characters and conversely for large fonts.

Scaling a single fonts to 17pt will result in thicker stems and curves; scaling it to 7pt will make for thin stems and curves. This is easily visible when capital letters are scaled down for faking small caps.

An easy example compile the following file first with the [sc] option, then without (so fake small caps will be used in the latter case).

enter image description here enter image description here

The difference is clear: compare the stems of F and K in the two cases.

Some OpenType fonts have different optical sizes, but they're commercial and expensive. The vast majority only have one size to be scaled. Good hinting helps at smaller sizes, but at bigger sizes the scaling is very evident.

Compile the following with XeTeX:

\font\testhuge="EB Garamond" at 17pt
\font\testbig="EB Garamond" at 12pt
\font\testnormal="EB Garamond" at 10pt
\font\testsmall="EB Garamond" at 7pt
\font\testtiny="EB Garamond" at 5pt

\offinterlineskip\testnormal

{\testhuge ABCDE}
\vskip1pt
{\testbig ABCDE}
\vskip1pt
ABCDE
\vskip1pt
{\testsmall ABCDE}
\vskip1pt
{\testtiny ABCDE}

\bye

enter image description here

You may have to use [EBGaramond12-Regular.otf] instead of "EB Garamond". It's very clear how bigger size appear much thicker and conversely for smaller sizes.

In cases like these, it makes sense to use a different font (for instance sans serif) for big sizes; not with Garamond, of course, for which the solution is not using big sizes.