7

I am preparing a document, which facilitates package fontspec to define the main- and the sans-font. In that document, I'd like to compare that main font with Computer Modern or—to be precise—it successor Latin Modern.

I was convinced, that writing

\newfontfamily\lmfont{Latin Modern Roman}

would enable the complete family with all its 70+ font files. But that is not correct.

For example, when I say

{\lmfont\scshape{}abcd} {\scshape{}abcd}

I get this:

Comparison of Small Capitals

On the left side the Latin modern font, but without the small caps :-(, on the right hand side, the default ("mainfont") font of the document as it should look like.

For my comparison, I'd like to present a great selection/combination of fonts in this family, i.e. the roman, sans and mono fonts added with shapes and faces like -italic, -italic-bold, -slanted, -slanted-bold, -bold, -smallcaps.

Unfortunately, my solution only loads the LMRoman10-Regular and LMSans10-Regular fonts, but not LMRomanCaps10-Regular. Thats why \lmfont\scshape (or \lmfont\ttfamily) didn't work.

So, is there a possibility, to define the \newfamily that it contains the complete Latin Modern fonts?

Any solution, which enables me, to have a simple macro to compare the two font families side by side would be fine.

Here is a MWE:

\documentclass{scrbook}
\usepackage{fontspec}

\setmainfont{Times New Roman} % and other definitions
\newfontfamily\lmfont{Latin Modern Roman} % this is not complete!!

%% New command to compare.  
%% #1 defines the family/shape/series
\newcommand{\compare}[1]{%
  {#1%
    ABCD \dots{} XYZ, abcd \dots{} xyz\\
    \lmfont{}ABCD \dots{} XYZ, abcd \dots{} xyz\par
  }
}

\begin{document}
\compare{\upshape}
\compare{\itshape}
\compare{\itshape\bfseries}
\compare{\scshape}
\end{document}

2 Answers 2

9

No, it doesn't work like that and it really can't.

There exists no font naming convention and various fonts do very different things. Some fonts have a smcp feature, others don't and one has to specify the font to use for small caps.

Latin Modern Roman is in a very different situation: there are about 70 font files and it's out of the scope of fontspec to analyze them in order to do all necessary assignments.

However, for the particular case, .fd files are available, so you can use them.

\documentclass{article}
\usepackage{fontspec}

\setmainfont{EB Garamond}

\newfontfamily\lmodern{Latin Modern Roman}[
  NFSSFamily=lmr
]

\begin{document}

Abc\textsc{Abc}

\lmodern

Abc\textsc{Abc}

\end{document}

enter image description here

4

As an addendum to egreg’s excellent answer: for a custom font that stores small caps in a separate file, for example named SomeFont-RegularSC.otf and SomeFont-BoldSC.otf, you would load them with

\newfontfamily\somefont{SomeFont}[
   UprightFont = *-Regular ,
   SmallCapsFont = *-RegularSC ,
   BoldFont = *-Bold ,
   BoldFeatures = { SmallCapsFont = *-BoldSC },
   % Etc.
   Extension = .otf ]

You can also put this command in a file named SomeFont.fontspec so that you can write \newfontfamily\somefont{SomeFont} in your documents. This avoids leaving dependencies on one particular version of the font in all your documents.

1
  • Thank you, that was very interesting and helpful!
    – Jan
    Dec 8, 2019 at 21:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .