khaledhosny / harftex

A TeX enginge with embedded HarfBuzz and Lua
GNU General Public License v2.0
30 stars 0 forks source link

Warning about missing script with unicode-math #3

Closed u-fischer closed 5 years ago

u-fischer commented 5 years ago
\documentclass{article}
\usepackage{harfload}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\begin{document}
abc
\end{document}

leads to lots of warnings with

Package fontspec Warning: OpenType feature 'Style=MathScriptScript' (ssty) not
(fontspec)                available for font 'LatinModernMath' with script
(fontspec)                'Math' and language 'Default'.

Without harfload there are no warnings. In case that there is something wrong in fontspec or the luaotfload-code: it is imho better if such issues are corrected at the source than trying to patch around. I will then move the issue to the right place.

khaledhosny commented 5 years ago

Fontspec does not set mode when checking for supported font scripts/languges/features which is IMO incorrect; if the font is going to be used with, say, mode=base then it should be checked with the same mode.

Right now, if no mode is set then harfload assumes mode=harf as IMO is a reasonable to assume if one is loading the package that fonts should by default be loaded with it.

I think fontspec should:

  1. not set mode at all by default since the default should be controlled by luaotfload/harfload (except when it have to, e.g. for math fonts)
  2. check the fonts with the same mode it is going to use them with.

That being said, this check shouldn't fail.

u-fischer commented 5 years ago

I don't think that it is a fontspec problem. The following prints "true" without harfload, but "false" with harfload/harftex:

\documentclass{article}
%\usepackage{harfload}
\begin{document}
\makeatletter 
\font\test={Latin Modern Math}\test abc
\directlua{print(luaotfload.aux.provides_feature(\fontid\test,"math","dflt","ssty"))}
\end{document}
khaledhosny commented 5 years ago

Yes, the provides_feature is giving the wrong result here and needs to be fixed. I'm overriding luaotfload.aux.provides_feature() to use HarfBuzz functions for fonts loaded with it, the fontspec issue is that it does not set mode when loading the font for checking, so it ends up checked with HarfBuzz even though it will be loaded later with base mode.

u-fischer commented 5 years ago

I just realized that I added the issue to the wrong repo, it should have gone to harf, not harftex. Sorry.

Yes, forcing mode=node makes the test working again. But assuming that the harf-test variant works ok, would it be faster than the orginal? If yes wouldn't it be better if fontspec would test features in harf-mode when available?

khaledhosny commented 5 years ago

It is actually an engine bug (bug in luaharfbuzz module to be exact), so this is the right repo.

harf mode might faster in loading fonts, but since the font will be loaded with luaotfload eventually then it might not make much of a difference in practice. Also the harf checks will return false for features that don't actually exist in the font (like tlig or anum or any user supplied feature) which is probably undesired.