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

Font warnings with lualatex-dev on Texlive #409

Closed callegar closed 4 years ago

callegar commented 4 years ago

Description

Trying lualatex-dev on TeXlive, that is luahbtex 1.11.2 with the pre-release latex format, that is LaTeX2e <2020-02-01> pre-release-3 (develop 2020-1-27 branch), I am getting a lot of font warnings, all of them related to bx series, on documents that compile with no warning with the regular lualatex 1.10.0 with the latex format <2019-10-01> patch level 3.

Specifically I see lots of entries like

LaTeX Font Warning: Font shape `TU/STEP(0)/bx/n' undefined
(Font)              using `TU/STEP(0)/b/n' instead on input line 1111

The issue seems to be triggered by the instancing of all the font series to modify the spacing as IEEEtran.cls does.

Check/indicate

Minimal example demonstrating the issue

The example below uses the article class, incorporating the font spacing logic from IEEEtran

\documentclass{article}
\makeatletter
\newdimen\@IEEEtrantmpdimenA
\newdimen\@IEEEtrantmpdimenB
\newdimen\@IEEEtrantmpdimenC

\def\@IEEEinterspaceratioM{0.35}
\def\@IEEEinterspaceMINratioM{0.23}
\def\@IEEEinterspaceMAXratioM{0.50}

\def\@IEEEinterspaceratioB{0.375}
\def\@IEEEinterspaceMINratioB{0.23}
\def\@IEEEinterspaceMAXratioB{0.55}

\def\@@@IEEEsetfontdimens#1#2#3{{%
    \setlength{\@IEEEtrantmpdimenB}{\f@size pt}
    % grab the font size in pt, could use 1em instead.
    \setlength{\@IEEEtrantmpdimenA}{#1\@IEEEtrantmpdimenB}%
    \fontdimen2\font=\@IEEEtrantmpdimenA\relax
    \addtolength{\@IEEEtrantmpdimenA}{-#2\@IEEEtrantmpdimenB}%
    \fontdimen3\font=-\@IEEEtrantmpdimenA\relax
    \setlength{\@IEEEtrantmpdimenA}{#1\@IEEEtrantmpdimenB}%
    \addtolength{\@IEEEtrantmpdimenA}{-#3\@IEEEtrantmpdimenB}%
    \fontdimen4\font=\@IEEEtrantmpdimenA\relax}}

% revise the interword spacing for each font weight
\def\@@IEEEsetfontdimens{{%
    \mdseries
    \@@@IEEEsetfontdimens{\@IEEEinterspaceratioM}{\@IEEEinterspaceMAXratioM}{\@IEEEinterspaceMINratioM}%
    \bfseries
    \@@@IEEEsetfontdimens{\@IEEEinterspaceratioB}{\@IEEEinterspaceMAXratioB}{\@IEEEinterspaceMINratioB}%
  }}

% revise the interword spacing for each font shape \slshape is not often
% used for IEEE work and is not altered here. The \scshape caps are
% already a tad too large in the free LaTeX fonts (as compared to what the
% IEEE uses) so we won't alter these either.
\def\@IEEEsetfontdimens{{%
    \normalfont
    \@@IEEEsetfontdimens
    \normalfont\itshape
    \@@IEEEsetfontdimens
  }}

\def\IEEEtunefonts{{\selectfont\rmfamily
    \tiny\@IEEEsetfontdimens
    \scriptsize\@IEEEsetfontdimens
    \footnotesize\@IEEEsetfontdimens
    \small\@IEEEsetfontdimens
    \normalsize\@IEEEsetfontdimens
    \large\@IEEEsetfontdimens
    \LARGE\@IEEEsetfontdimens
    \huge\@IEEEsetfontdimens
    \Huge\@IEEEsetfontdimens}}

\makeatother
\usepackage{unicode-math}
\setmainfont{STEP}
\IEEEtunefonts
\begin{document}
hello \emph{hello}
\end{document}

Further details

I would like to find out whether this is an issue with the new font management logic or an expected behavior, to know how IEEEtran.cls will need to be patched to make it compatible with future lualatex.

wspr commented 4 years ago

This should now be fixed with an updated fontspec (v2.7h) — could you please check?

callegar commented 4 years ago

Unfortunately, not. The other way round, I now see the warnings also with regular lualatex, not just with lualatex-dev. I think that this is because the LaTeX format has now been updated to what was its pre-release at the time of submitting the bug.

wspr commented 4 years ago

Can you provide a document that uses a font in TeX Live? Preferably more minimal than the example above?

wspr commented 4 years ago

Apologies, I just re-ran in LuaLaTeX instead of XeLaTeX and I see the font is indeed available in TeX Live.

wspr commented 4 years ago

Here's a truly minimal example:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{STEP}
{\bfseries}
\begin{document}
hello \emph{hello} \textbf{hello}
\end{document}

Sorry, I can't spend more time on this tonight...

callegar commented 4 years ago

Thanks for minimalizing my example. I had tried playing with \bfseries, but at the beginning I did not notice that it had to be placed before the \begin{document} to see the issue!!!

u-fischer commented 4 years ago

@wspr It is the already discussed problem. One way to resolve it would be if fontspec defines both b and bx:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{STEP}
\DeclareFontShape{TU}{\familydefault}{bx}{n}{<-> ssub*\familydefault/b/n}{}
{\bfseries}
\begin{document}
hello \emph{hello} \textbf{hello}
\end{document}
wspr commented 4 years ago

@u-fischer — the working branch now has a fix for this (see above). Do you think I should push this out straight away?