lualatex / luaotfload

OpenType font loader for LuaTeX
Other
26 stars 8 forks source link

Messed up font names #95

Closed simifilm closed 11 years ago

simifilm commented 11 years ago

I'm not sure whether this is a duplicate or not. If it is, sorry for the noise.

While playing around with lualatex on TL 13 I encountered a strange problem. Certain font shapes would produce an error without any visible reason. The following example is with Stempel Garamond LT Std from Adobe's Font Folio 11, but I've encountered this with other fonts as well.

\documentclass[]{scrbook}

\usepackage{fontspec}
\setmainfont[Ligatures=TeX,ItalicFont={Stempel Garamond LT Std Italic},BoldFont={Stempel Garamond LT Std Bold},BoldItalicFont={Stempel Garamond LT Std Bold Italic}]{Stempel Garamond LT Std Roman} 
\begin{document}

Regular \textbf{bold}  \emph{italics \textbf{bold italics}}  

\end{document}

This leads to the following error message:

LaTeX Font Info:    Font shape `EU2/StempelGaramondLTStdRoman(0)/m/sl' in size <10.95> not available
(Font)              Font shape `EU2/StempelGaramondLTStdRoman(0)/m/it' tried instead on input line 10.
luaotfload | load: auto-selecting default features for script: latn
luaotfload | load: no defaults for script “latn”, falling back to “dflt”
luaotfload | load: invalid request “/Users/simi/FontExplorerX/S/Stempel” of type anon
luaotfload | load: use square bracket syntax or consult the documentation.
luaotfload | load: path lookup of “/Users/simi/FontExplorerX/S/Stempel” unsuccessful, falling back to file: ! Font \EU2/StempelGaramondLTStdRoman(0)/m/it/10.95=/Users/simi/FontExplorerX/S/
Stempel not loadable: metric data not found or bad.
<to be read again> 
G

According to the answer given on tex.stackexchange.com the problem is the following:

This seems to be a bug in luaotfload and/or luatex with \fontname. It is triggered here because fontspec declares the italic font as a substitute for the (non-existent) slanted font. This will call latex's \do@subst@correction, which uses \fontname\font to load the substitute font. But with luatex (and luaotfload), \fontname\font wrongly returns the full path of the font (in your case /Users/simi/FontExplorerX/S/Stempel Garamond LT Std Italic/StempelGaramondLTStdItalic.otf) instead of its "name" ("StempelGaramondLTStdItalic:mode=node;script=latn;language=DFLT;+tlig;+trep;" at 10.95pt). This in turn will make \font explode.

You can prevent this from happening by specifying the slanted font explicitly, thus circumventing the substitution mess:

     ItalicFont={Stempel Garamond LT Std Italic},
     SlantedFont={Stempel Garamond LT Std Italic},
     BoldFont={Stempel Garamond LT Std Bold},
     BoldItalicFont={Stempel Garamond LT Std Bold Italic},
     BoldSlantedFont={Stempel Garamond LT Std Bold Italic}]
   {Stempel Garamond LT Std Roman}

This solution does indeed work.

phi-gamma commented 11 years ago

First of all thanks for reporting. I meditated on the issue a bit yesterday and came up with this:

https://phi-gamma.net/archives/luaotfload.zip
https://phi-gamma.net/archives/luaotfload.tds.zip

md5sums:

90482d666e3234c19a82d0eca1b9bdae  luaotfload.tds.zip
9048ee1156ba1b33aca028d17314a6a7  luaotfload.zip

Please test. Note that this is a snapshot of my unstable branch. It will require the names database to be rebuilt since its structure has been largely rewritten. Also the compatibility hacks are gone, so it won’t work with a fontspec older than the TL 2013 version.

phi-gamma commented 11 years ago

And btw, here’s a test file for Plain that shows how \fontname is handled now.

https://bitbucket.org/phg/lua-la-tex-tests/src/9e87e4d91e0/pln-fontname-1.tex

You can test it agains Xetex and Luatex-Plain to compare their behaviors.

simifilm commented 11 years ago

This does indeed solve the problem. Thanks a lot. I guess this fix comes too late for TL 13?

phi-gamma commented 11 years ago

Yes, sorry. The changes are too radical to sneak them past the freeze. Once I’m done removing the compatibility stuff I’ll upload v 2.3 to CTAN. Thanks for testing!

phi-gamma commented 11 years ago

fixed with https://github.com/lualatex/luaotfload/pull/96