latex3 / fontspec

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

fontspec/luatex font weight/optical size issues #105

Open zhouyan opened 13 years ago

zhouyan commented 13 years ago

This is a little bit related to issue #7.

fontspec when use with luatex, select "wrong" font weights and optical size, here is a minimum example,

\documentclass{article}
\usepackage[no-math]{fontspec}
\usepackage{pgffor}
\setmainfont{Minion Pro}

\long\def\testtext{
  \par\textrm{Normal}
  \par\textit{Italic}
  \par\textsc{SmallCaps}
  \par\textbf{Bold}
  \par\textbf{\textit{BoldItalic}}
  \par\textbf{\textsc{BoldSmallCaps}}
  \par\textsc{\textit{ItalicSmallCaps}}
  \par\textbf{\textsc{\textit{BoldItalicSmallCaps}}}
}

\long\def\testfont{
  \foreach \size in {5, 8.4, 10, 13, 14, 19.9, 24}
  {{\fontsize{\size pt}{\size pt}\selectfont \size pt\par\testtext\par}}}

\begin{document}
  \testfont
\end{document}

Under Mac OS X 10.6.7, with updated TeXLive 2010, luatex is 64bit. The the automatically selected optical size is simply a mess. Using Acrobat to investigate the selected fonts for each word, it is found that "Italic Caption" and "Bold Caption" are used for 24pt fonts while 14 point fonts are mixed with "Sub head" and "Regular".

Now change the \setmainfont to the following,

\setmainfont[SizeFeatures = {
  {Size =     -8.41, OpticalSize = 8},
  {Size = 8.41-13.1, OpticalSize = 11},
  {Size = 13.1-20.0, OpticalSize = 19},
  {Size = 20.0-,     OpticalSize = 72}}
]{Minion Pro}

With this setup, correct optical fonts are selected. (The reason I use numbers like 8.41 instead of the 8.4 in Minion Pro is that fontspec use X <= s < Y in size range. For example with \fontsize{13}{13}, and the actual fontsize TeX use is 12.97, if I set Size = 8.4-13, then Subhead is used by fontspec, since the 13 >= 13 white the actually used font 12.97 <= 13. So I shifted the range a little bit.)

Anyway, with the above setup, optical size now works fine.

For the weight, Bold{(\textbf), Italic(\textit), Bold Italic(\textbf{\texit{}}) all works fine. But the regular fonts is a mess. And it seems to be platform dependent, so I guess this is more or less a problem with the interaction of fontspec with luatex or purely a problem with luatex.

To be more specific, On my Mac, the following weights are used for regular fonts (no bold, no italic). In the following I use "Regular" weights to refer to MinionPro-Capt.otf, MinionPro-Disp.otf, etc. Caption: Regular Text: Medium Subh: Medium Disp: Regular

But on my RHEL 6.1, still with updated TeXLive 2011, the weights chosen are, Caption: Medium Text: Regular Subh: Regular Disp: Medium

Though "Medium" and "Regular" do differ very little. But this randomness output is just too strange.

I tried to specify specific fonts for each optical size and bold/italic, but as in issue #7, I cannot get it work.

A simple workaround is to exclude the medium weight font when running mkluatexfontdb, so fontspec or luatex won't be confused.

adunning commented 5 years ago

I cannot reproduce this under TeX Live 2018.