[Tex/LaTex] setting font size in XeLaTeX

fontsfontsizefontspecxetex

Previous questions have sought a straightforward way to specify font size (e.g., in points) of a new font family when using fontspec. One reason for why this might be needed is that some journals require specific font sizes of various pieces of text—such as 9.5pt or 11.5pt, which most document classes don't support.

Previous popular answers have suggested using Scale, which can supposedly simply act as a factor to the font size that is fed to the document class in order to have control over specific font size. For example, if 10pt is specified for the document class, and Scale=1.2 for a new font family, then one should expect that font to display at a size of 12 points.

Using Scale in this way works fine when the font being scaled is the main font. However, when a different font is involved, Scale=1.0 produces a different size font than Scale=MatchLowercase. With the example above, with a document font size of 10pt, I presume this new font would also be 10pt using Scale=MatchLowercase and not Scale=1.0. However, I don't understand enough about the inner workings of fontspec or font metrics in general to know if this is right.

A mwe of this example is provided here:

\documentclass[10pt]{article}

\usepackage{fontspec}

\setmainfont{DejaVu Serif}
\setsansfont[Scale=MatchLowercase]{DejaVu Sans}

\newfontfamily\dejavuseriften[Scale=1.0]{DejaVu Serif}
\newfontfamily\dejavuseriftwelve[Scale=1.2]{DejaVu Serif}

\newfontfamily\dejavusansten[Scale=1.0]{DejaVu Sans}
\newfontfamily\dejavusanstwelve[Scale=1.2]{DejaVu Sans}

\begin{document}

   This is a test of DejaVu Serif, as mainfont\\

   {\dejavuseriften This is a test of DejaVu Serif, Scale=1.0}\\

   {\dejavuseriftwelve This is a test of DejaVu Serif, Scale=1.2}\\


   \textsf{This is a test of DejaVu Sans, MatchLowercase}\\

   {\dejavusansten This is a test of DejaVu Sans, Scale=1.0}\\

   {\dejavusanstwelve This is a test of DejaVu Sans, Scale=1.2}\\

\end{document}

Output:
output of mwe

In this example, two DejaVu fonts are used, so the different fonts with equal values of Scale appear to be about the same size. However, when the fonts are entirely different, this is not the case. A modified version of the mwe above, with Latin Modern Sans instead of DejaVu Sans, is provided here:

\documentclass[10pt]{article}

\usepackage{fontspec}

\setmainfont{DejaVu Serif}
\setsansfont[Scale=MatchLowercase]{Latin Modern Sans}

\newfontfamily\dejavuseriften[Scale=1.0]{DejaVu Serif}
\newfontfamily\dejavuseriftwelve[Scale=1.2]{DejaVu Serif}

\newfontfamily\lmsansten[Scale=1.0]{Latin Modern Sans}
\newfontfamily\lmsanstwelve[Scale=1.2]{Latin Modern Sans}

\begin{document}

   This is a test of DejaVu Serif, as mainfont\\

   {\dejavuseriften This is a test of DejaVu Serif, Scale=1.0}\\

   {\dejavuseriftwelve This is a test of DejaVu Serif, Scale=1.2}\\


   \textsf{This is a test of Latin Modern Sans, MatchLowercase}\\

   {\lmsansten This is a test of Latin Modern Sans, Scale=1.0}\\

   {\lmsanstwelve This is a test of Latin Modern Sans, Scale=1.2}\\

\end{document}

Output:
output of second mwe

In this example, the MatchLowercase version of Latin Modern Sans appears to be the same size as the DejaVu Serif main font, while the Scale=1.0 version appears to be much smaller.

My question is whether using Scale like this to set exact font sizes is really a reasonable approach. If so, then is the assumption that even though the second font "looks" like it's a different size at a numerically equal scale, it's really the same size, in font points? An accompanying good explanation of the relevant aspects of font metrics and/or fontspec are also welcome.

Best Answer

use the SizeFeature instead of Scale. The last line shows that the two 10pt lines have the same height:

\documentclass[10pt]{article}
\usepackage{fontspec}
\parindent=0pt
\setmainfont{DejaVu Serif}
\setsansfont[Scale=MatchLowercase]{Latin Modern Sans}

\newfontfamily\dejavuseriften[SizeFeatures={Size=10}]{DejaVu Serif}
\newfontfamily\dejavuseriftwelve[SizeFeatures={Size=12}]{DejaVu Serif}

\newfontfamily\lmsansten[SizeFeatures={Size=10}]{Latin Modern Sans}
\newfontfamily\lmsanstwelve[SizeFeatures={Size=12}]{Latin Modern Sans}

\begin{document}
This is a test of DejaVu Serif, as mainfont\\
{\dejavuseriften This is a test of DejaVu Serif, Size=10\\}
{\dejavuseriftwelve This is a test of DejaVu Serif, Size=12\\}

This\textsf{This is a test of Latin Modern Sans, MatchLowercase\\}% compare 
%loercase
{\lmsansten This is a test of Latin Modern Sans, Size=10\\}
{\lmsanstwelve This is a test of Latin Modern Sans, Size=12\\}

\makebox[0pt][l]{This is a test of DejaVu Serif, as mainfont}%
{\lmsansten This is a test of Latin Modern Sans, Size=10\\}

\end{document}

enter image description here

Related Question