# How can I scale mono font to 90% of MatchLowercase

I would like to scale the mono font so that it's x-height is 90% of the x-height of the main font. (I think it looks too large when the x-height matches.) Is this possible?

Sample code with matching x-heights:

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Source Serif Pro}[Scale=0.94]
\setsansfont{Source Sans Pro}[Scale=MatchLowercase]

% Want 0.9 * MatchLowercase here:
\setmonofont{Latin Modern Mono}[Scale=MatchLowercase]

\newcommand\fox{The quick brown fox jumps over the lazy dog.}
\begin{document}
\fox\par
\textsf{\fox}\par
\texttt{\fox}\par
\end{document}

• I’m not sure how 0.9 * MatchLowercase can be achieved. But it is worth mentioning that Source Serif/Sans Pro seem to have very distinct cap height and ascender, while for Latin Modern Mono these two metrics are very close, e.g., the Th part. This could affect the visual appearance of the font size. IMO, using two MatchLowercase’s (i.stack.imgur.com/EJT9c.png) produces sans too small. Using two MatchUppercase’s looks like this: i.stack.imgur.com/G9fLF.png. – Ruixi Zhang Oct 2 '18 at 4:07

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Source Serif Pro}[Scale=0.86] %=0.94*0.9
% Want 0.9 * MatchLowercase here:
\setmonofont{Latin Modern Mono}[Scale=MatchLowercase]

\setmainfont{Source Serif Pro}[Scale=0.94]
\setsansfont{Source Sans Pro}[Scale=MatchLowercase]
\newcommand\fox{The quick brown fox jumps over the lazy dog.}
\begin{document}
\fox\par
\textsf{\fox}\par
\texttt{\fox}\par
\end{document}

• Well that's clever. Is there a way that the 0.94 can be saved in a "variable" somehow, so it's not effectively repeated? This doesn't work:\newcommand\myscale{0.94} \setmainfont{Source Serif Pro}[Scale=0.9\myscale] [...] \setmainfont{Source Serif Pro}[Scale=\myscale]  – dedded Oct 2 '18 at 12:57
• \usepackage{xfp} and Scale=\fpeval{\myscale*0.9} should work. – Ulrike Fischer Oct 2 '18 at 13:04

I've gotten a good year of use of Ulrike's answer (thank you!), but there is now a better way. Or maybe it was always there and I never noticed it. In any case, this is a straight-forward way of doing it with fontspec's ScaleAgain facility:

\setmonofont{Latin Modern Mono}[
Scale       = MatchLowercase ,
ScaleAgain  = 0.9 ,
]

• Huh. I didn’t know about that, either. You saved me from writing code to find the x-height of both fonts and take the ratio. – Davislor Oct 16 '19 at 5:15
• Really a good catch... – MadyYuvi Oct 16 '19 at 7:05