3

I'm trying to mix and match fonts, using a beta OTF font that a colleague recommended. But when I load the font at its default size, it's not a good fit with Computer Modern. I need \normalsize to mean something smaller for Carob than what it means for Computer Modern. example of text at two heights As you can see in the example, the Carob text is too big. I need to tell XeLaTeX to shrink it down so that it looks to be about the same height as ttfamily there. I can find a good height experimentally, but how do I tell XeLaTeX that \normalsize should mean that height?

I will want to do something similar for \small and \footnotesize.

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\carob{Carob Mono}
\begin{document}
\noindent 
\thispagestyle{empty}
Primitives are standard.
This text is {\ttfamily ttfamily} and this is {\carob Carob}.
\end{document}

Edited to add: I would love to be able just to provide some kind of scaling option to the \newfontfamily command, but a look through the fontspec manual did not reveal such a thing.

  • 1
    You can use the Scale key when setting up one of the fonts with fontspec. See e.g. https://tex.stackexchange.com/questions/141694/change-default-font-size-while-using-fontspec?rq=1#comment320333_141694 (but you might want to use it for the non-main font, of course, which would probably make more sense here). – cfr Nov 12 '19 at 23:21

1 Answers1

3

Use Scale as below. You have two choices: scaling to match the uppercase letters of the main font or the lowercase ones.

Typically, the second option is used for monospaced fonts. For instance, Latin Modern Mono has shorter capitals than Latin Modern Roman, but matching lowercase.

I used a different font, which however is distinctly higher than Latin Modern.

\documentclass{article}
\usepackage{fontspec}

\newfontfamily\carobA{Lucida Sans Typewriter OT}
\newfontfamily\carobB{Lucida Sans Typewriter OT}[Scale=MatchUppercase]
\newfontfamily\carobC{Lucida Sans Typewriter OT}[Scale=MatchLowercase]

\begin{document}

This text is {\ttfamily ttfamily} and this is X{\carobA Carob}a.

This text is {\ttfamily ttfamily} and this is X{\carobB Carob}a.

This text is {\ttfamily ttfamily} and this is X{\carobC Carob}a.

\end{document}

enter image description here

egreg
  • 1,121,712