# Using \fontsize in XeLaTeX and LuaLaTeX

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?

• “Unbalanced thickness” seems a reference to the kind of problem optical sizes are meant to correct. If you use fonts with optical sizes in luatex or xetex, you won’t have the problem. If you use fonts without, you may notice it, just as you would with pdftex or other engines. Jan 22, 2015 at 20:35
• And do all the "good" (that is, professional) fonts come with optical sizes? For instance, I'm currently using MinionPro, which is as professional as they get. Jan 22, 2015 at 20:38
• Few professional fonts do, unfortunately, and for Minion Pro you have to buy them (the cuts that come with the PDF reader are sized for body text). EB Garamond has two optical sizes so far. Jan 22, 2015 at 20:41
• There is a revival of Centaur with optical sizes underway at benwhitmore.altervista.org Jan 22, 2015 at 20:47
• There are many professional font with optical sizes. On the Adobe side, for instance, you have Minion Pro, but Garamond Premier, Chaparral, Arno and Warnock as well. You can find out which typeface has optical sizes in sites like myfonts.com Jan 22, 2015 at 20:53

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.

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).

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


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.

The quotation (and hence the question:-) seem to be mixing up different concepts.

There is the difference between having fonts at a design size or simply magnifying them. (so the difference between cmr10 scaled to 12pt and cmr12, as shown in other answers). Note this is really a distinction about the computer modern fonts rather than about TeX or the difference between pdftex and xetex or luatex. Even using classic TeX at 10pt document size latex uses a mixture of design size and scaled fonts \LARGE, \huge and \Huge for example are all scaled versions of cmr17, and if you use the [11pt] document class option then the default "11pt" font is a scaled version of cmr10. Conversely, if using pdftex with most scalable font families (such as Times) the fonts are available just at one notional 10pt size so a scaled font is used for all sizes.

Using fontspec does not really change this, it gives access to more fonts and more of those are only available at one design size, but it can allow specification of different design sizes, and does for example for latin modern which replaces computer modern as default.

LaTeX uses the same logic to choose whether to use a scaled font for a specific size irrespective of whether that is selected by \huge or \fontsize{}{] in fact \huge is just a macro that expands to \fontsize. So the choice of whether to use named sizes or explicit lengths is unrelated to the issue of design size fonts. using lots of different font sizes in a document is distracting and normally considered a bad idea, so using \scalebox to scale text is a dubious practice as is using \fontsize{3cm}{2in} with different sizes in every paragraph. using the class-specified named font sizes helps preserve a consistent look and applies whether or not those sizes are implemented by scaling the same font or by using separate design size fonts or a mixture of the two.

Example of "correctly balanced thickness", using Computer Modern, and with a large zoom factor on the PDF before I made the screenshot:

\documentclass{article}
\begin{document}
{\Huge ABCDEF}

ABCDEF
\end{document}


Compare the height of the A to the width of its right serif. The larger size is roughly 281 pixels high, and the serif is roughly 85 pixels wide (30% ratio). The regular size is roughly 113 pixels high, and the serif roughly 38 pixels wide (33% ratio). Each font size has slightly different dimensions in many attributes to make things more readable at all sizes.

By comparison, a simple XeLaTeX example:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Calibri}
\begin{document}
{\Huge ABCDEF}

ABCDEF
\end{document}


shows constant ratios for any given pair of lengths at both sizes. Font sizes are simply scaled up or down here.

Unbalanced thickness may refer to the fact that a scaled font produces as a consequence thicker large characters and thinner small characters, always in comparison to the «normal» or intended size of the given font.

If you have a family typeface with different optical sizes (as, for instance, Minion Pro), you can balance the character weight, so that titles, captions and so on, look mostly like the regular/normal font, i.e., nor lighter nor bolder. Of course, you can modify these options to your taste.

In case you don't own different optical sizes, fontspec will only scale the font.