latex3 / fontspec

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

Fontspec fontname lookup issues with XeTeX and type1 fonts (e.g., picks bolditalic for italic, semibold for bolditalic, etc.) #419

Closed callegar closed 4 years ago

callegar commented 4 years ago

Description

Fontspec + XeTex seems to select wrong font variants, when fonts are specified by name and postscript fonts are around.

Consider the example below, a minimal test file using the Libertinus font. The source does always work right with lualatex. However, with xelatex, if the type1 version of Libertinus is around (Texlive package libertinus-type1), then bolditalic is incorrectly chosen in place of italic and semibold is incorrectly chosen in place of bolditalic.

To better illustrate my setup, I have an ubuntu (in fact kubuntu) 19.10 machine, where I use the pristine texlive 2019 (not the texlive provided via deb files in the distro). My texlive has constantly been updated until texlive 2019 updates were halted to develop texlive 2020. I am exposing all the opentype, truetype and type1 texlive font dirs to the system, by a fontconfig configuration file, as suggested in the texlive installation instructions.

In this situation, the system sees both the opentype and the type1 versions of libertinus (because I have both the libertinus-otf and libertinus-type1 tex packages, and xetex picks wrong fonts.

If I hide the type1 fonts from the system, then xetex picks the right font. If I hide the opentype fonts, so that xetex can only see the type1 fonts, then xetex picks the wrong font. Hence the issue does not seem to be related to the fact that both versions of the font exist, rather it seems specific to type1.

It is unclear to me if the issue is related to fontspec or to xetex itself.

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Libertinus Serif}
\begin{document}
Test \emph{test} \textit{test} \textbf{test} \textbf{\textit{test}}.
\end{document}

Further details

I am also adding a log file, obtained with the tracing of fonts (\XeTeXtracingfonts 1). test.log

Note that fc match always returns the right fonts on the system. For instance, with only type 1 I get:

fc-match -f "%{file}\n" "Libertinus Serif:style=italic"
/usr/local/texlive/2019/texmf-dist/fonts/type1/public/libertinus-type1/LibertinusSerif-Italic.pfb
wspr commented 4 years ago

I'm sorry to have to close this after the detail you've included but fontspec does not have anything to do with font lookup, it just uses whatever the engine provides.

callegar commented 4 years ago

Nothing to be sorry. If I am correct it only means that I need to redirect this to the xetex issue tracker, right? This is already a quite useful piece of info!