latex3 / fontspec

Font selection in LaTeX for XeTeX and LuaTeX
http://latex3.github.io/fontspec/
LaTeX Project Public License v1.3c
277 stars 34 forks source link

FontFace only works for "new" NFSS series/shapes #295

Open u-fischer opened 7 years ago

u-fischer commented 7 years ago

With the FontFace option one can easily add more NFSS series/shapes, but it doesn't work for standard combinations:


\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}%
 [
  FontFace={m}{it}{TeX Gyre Heros/I},
  FontFace={blub}{it}{TeX Gyre Heros/I},
 ] 
\begin{document}
Test
\fontseries{m}\fontshape{it}\selectfont Test %fails
\fontseries{blub}\fontshape{it}\selectfont Test %works

\end{document}

fontface

Would it be possible to either change FontFace or to add e.g. a FontFace* key that allows to overwrite the fonts choosen by fontspec? For large and complicated font declarations it is much easier to use FontFace (if one knows a bit about NFSS ;-)) than to nest ItalicFeatures, SmallCapsFont and the like.

(It would be quite okay if the overwriting could be done only in a second, separate command/step and involved a NFSSFamily-name).

wspr commented 7 years ago

Hmm, that isn’t intentional. I agree you would expect to be able to make all definitions via FontFace. Will investigate...

u-fischer commented 7 years ago

It is certainly what I expect (and want) but the manual speaks only about additional shapes so I couldn't claim that my expectation is documentated ;-).

wspr commented 7 years ago

Strange, for me (still on TL2016 on this laptop), the following works okay for me:

\usepackage{fontspec}
\setmainfont{texgyretermes-regular.otf}%
 [
  FontFace={m}{it}{texgyreheros-italic.otf},
  FontFace={blub}{it}{texgyreheros-italic.otf},
 ] 
\begin{document}
Test
\fontseries{m}\fontshape{it}\selectfont Test %fails
\fontseries{blub}\fontshape{it}\selectfont Test %works
\end{document}

Something to do with the /I? I rarely invoke fonts like this any more so I'm a bit out of practice…

u-fischer commented 7 years ago

The /I is not the problem. The problem seems to be the call by font name. It fails e.g. also if I use "Arial" or FontFace={m}{it}{TeX Gyre Heros}. So probably something leaks out while fontspec accesses the font.

Loading by file names seems to work in most cases. But e.g. not with ariali.ttf: lualatex can find and use the file but not in the FontFace={m}{it}, while xelatex doesn't find it at all.

(Regarding the use of the /I. I look this things up in the log-file. fontspec is so considerate to tell how it calls the fonts ;-)).

niluxv commented 1 month ago

Another related issue that tripped me recently: even when using filenames FontFace = {m}{n} (so default series, default shape) does not work. Other combinations like FontFace = {b}{n} do work for me, which makes it a bit surprising.

\documentclass{article}
\usepackage{fontspec}

\setmainfont{lmroman10-italic.otf}[
%     UprightFont = {lmroman10-regular.otf}, % does work
    FontFace = {m}{n}{lmroman10-regular.otf} , % doesn't work
    FontFace = {b}{n}{lmroman10-bold.otf} , % does work
]

\begin{document}
    Normal font is printed in italics (lmroman10-italic), not regular (lmroman10-regular).

    \textbf{Bold font is printed in bold (lmroman10-bold).}
\end{document}