reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
185 stars 52 forks source link

Libertinus Serif font's small caps face doesn't work (needs a workaround) #624

Closed tlikonen closed 5 months ago

tlikonen commented 5 months ago

Libertinus Serif font family has small caps face but it does not work with Polyglossia normally. Here is an example document:

\documentclass{article}
%\usepackage[finnish]{babel}  % works with Babel
\usepackage{polyglossia} \setdefaultlanguage{finnish} % doesn't work with Polyglossia
\usepackage{fontspec}

\setmainfont{Libertinus Serif}

\begin{document}
\textsc{small caps} normal text
\end{document}

The \textsc{...} part is displayed with normal upright font face and there is an error in the compile output (lualatex):

LaTeX Font Warning: Font shape `TU/LibertinusSerif(1)/m/sc' undefined
(Font)              using `TU/LibertinusSerif(1)/m/n' instead on input line 13.

However, with Babel package, this all works without errors. I know two workarounds for Polyglossia. One is by adding \rmfamily command at the beginning of document environment.

\begin{document}
\rmfamily
\textsc{small caps} normal text
\end{document}

Another workaround is defining the font family with these options:

\setmainfont{Libertinus Serif}[
SmallCapsFont={* Regular},
SmallCapsFeatures={Language=Default, Letters=SmallCaps}]

I don't know it this is a Polyglossia bug but it triggers with it (and not with Babel), so I dare the report it here.

tlikonen commented 5 months ago

Actually the issue happens with Babel too if I set the font family with \babelfont:

\babelfont{rm}{Libertinus Serif}

With that command there must be the same font options as described in my previous message:

\babelfont{rm}[
SmallCapsFont={* Regular},
SmallCapsFeatures={Language=Default, Letters=SmallCaps}
]{Libertinus Serif}

So probably this is not much about Polyglossia and more about Libertinus Serif and Fontspec. I don't know.

Udi-Fogiel commented 5 months ago

I'm not sure what is the source of the problem, but I'm guessing it is a bug in fontspec. The problem occurs when fontspec try to load the font with the language tag (which polyglossia \babelfont is adding):

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Libertinus Serif}
\begin{document}
\textsc{small caps} normal text

\addfontfeature{Language=Finnish}
\textsc{small caps} normal text
\end{document}

notice in the log file how in the second loading of the font, the line (fontspec) - 'small caps' (m/sc) with NFSS spec.: is not followed by any description.

However, if I load the font directly with luaotfload, it seems to work:

\documentclass{article}
\usepackage{fontspec}

\begin{document}
\font\foo="LibertinusSerif:mode=node;script=latn;language=FIN;+tlig;"\foo
\textsc{small caps} normal text

\setmainfont{Libertinus Serif}[Language=Finnish]
\textsc{small caps} normal text
\end{document}

As a workaround, you can define the finish font with \newfontfamily\finishfont, this way polyglossia will not add any font features, and will use the font as you loaded it (so pass the desired features).

I'll close for now, but feel free to reopen if you think I misunderstood anything.

jspitz commented 5 months ago

Maybe related to https://github.com/latex3/fontspec/issues/449