4

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
4
\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.