Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

wrong font size with italic Latin Modern #30

Open
hennigs opened this issue May 13, 2011 · 1 comment
Open

wrong font size with italic Latin Modern #30

hennigs opened this issue May 13, 2011 · 1 comment

Comments

@hennigs
Copy link

hennigs commented May 13, 2011

The \textit command sometimes changes font size when using Latin Modern Roman or Latin Modern Sans.

\listfiles
\documentclass{book}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
%\setmainfont{Latin Modern Sans}
%\setmainfont{TeX Gyre Pagella}
%\setmainfont{GFSBodoni}
\newcommand*{\test}{foo \textit{bar} foo}
\begin{document}
\test
\tableofcontents
\mainmatter
\test
\end{document}

Below is a comment by U. F. from the lualatex list:

Yes. It has obviously to do with the fact that the fonts exist in
more than one size. lualatex reloads the fonts after a newpage and
then sometimes gets the wrong size (I could reproduce it with 10pt
and 12pt class options but not with 11pt).

I suspect a fontspec bug as one can trigger the wrong font size by
using \textsl. (fontspec handles slanted and italic in a specific
way):

\documentclass[12pt]{book}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\newcommand*{\test}{foo  \textit{bar} \textsl{cde} \textit{bar} foo}

\begin{document}
\test
\end{document}
@coronson
Copy link

There may be more than one bug involved in this issue. After some debugging effort, I found this chain of events:

  1. A suitable slanted font is not found by lualatex, and an italic font is substituted.

  2. Some LaTeX macro calls \do@subst@correction, which seems to specify the font without some size information, that is

    • no at <x>pt
    • no scaled <factor>
    • and definitely no size information in the font name, in my case just LatinModernRoman/I
  3. lualatex (maybe TeX in general, didn't check) assigns a default size of "scaled at 100% font design size"

  4. lualatex calls the define_font callback, and true to the description in the luatex reference manual, font size is encoded as

    • positive integers for a fixed size (in units of 1/65536 pt) [not in this case]
    • negative integers for scaled fonts (-1000 * scale factor)

    A size of "scaled at 100% font design size" is thus encoded as the integer -1000

  5. luaotfload does not handle scaled fonts in the define_font callback correctly, instead searching for a font of size -1000pt / 65536 = -0.0152587890pt. As a result, it always chooses the smallest size of the font.

There are at least two problems that I can see:

  1. The define_font callback in luaotfload is not prepared to handle scaled fonts, the sizes of which are encoded as negative values.

  2. The information given to this callback is not sufficient to select a font. The only information I got was

    • name: LatinModernRoman/I
    • size: -1000

    I'm not sure where this problem comes from, latex font seletion (the \do@subst@correction macro), fontspec, or luatex. What's more, I have no idea how luaotfload should handle scaled fonts when the font name resolves to more than one font.

As a workaround, I found that in my case, and the two code examples above, specifying the slanted font explicitly, by

\setmainfont[SlantedFont={Latin Modern Roman Slanted}]{Latin Modern Roman}

works, because it avoids font substitution (step 1). The problems with font substitution, however, remain.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants