latex3 / luaotfload

OpenType font loader for LuaTeX
Other
56 stars 6 forks source link

luaotfload and Math fonts: cvNN feature for superscripts not applied #266

Open dflipo opened 8 months ago

dflipo commented 8 months ago

This issue is similar to https://github.com/latex3/luaotfload/issues/227.

For the Math fonts I maintain, I use cvNN features to to toggle Greek variants in Maths, f.i. the cv06 feature makes \phi output mitvarphi (U+1D711) instead of mitphi (U+1D719) the default. It works fine for base characters, but I recently noticed a problem with the superscripts of these variants (bolder glyphs mitvarphi.st and mitvarphi.sst are available for the ssty feature): only one feature is applied by luaotfload, actually the last called by the font (not the first as I wrote previously).

I reported on SE (https://tex.stackexchange.com/questions/698768/) and after private exchanges with with Mikael Sundquist and Hans Hagen, they came up with a solution (thanks to both of them!) which works for me (see the appended "fontloader-2023-08-19.lua" file).

The following MWE: requires XCharter-Math v0.51 pushed to CTAN today. In this new version, feature ssty is applied last (it was applied before all cvNN features in previous versions). Screen captures of the compilation by current LuaLaTeX, XeLaTeX (correct output) and LuaLaTeX+patch (correct output) are appended.

`\documentclass{article} \usepackage{unicode-math} \usepackage{iftex} \begin{document} \setmathfont{XCharter-Math.otf} \ifluatex LuaLaTeX: \fi \ifxetex XeLaTeX: \fi

\vspace{.5\baselineskip} (\phi^{\phi^{\phi}}, v^{v^{v}})

\setmathfont{XCharter-Math.otf}[CharacterVariant={6,11}] (\phi^{\phi^{\phi}}, v^{v^{v}}) \end{document}`

Outputs (screen captures): image

image

After adding file "fontloader-2023-08-19.lua" to the current directory, the output is correct:

image

fontloader-2023-08-19.lua.zip

zauguin commented 8 months ago

@dflipo When you talked to Has Hagen about this, did he mention if he plans to add this change to ConTeXt MKIV soon too?

antonis-tsolomitis commented 6 months ago

This bug seems to remain unresolved. The above fix with the extra fontloader file does NOT work with StylisticSets. NewComputerModern is to provide scriptstyle and scriptscriptstyle glyphs for the alternate calligraphic Latin capitals. Let me call those "mathscr". The default is "mathcal" and StylisticSet=1 replaces mathcal with mathscr. This works fine with xelatex. But with lua only the base of an exponent is changed to mathscr. So if you write \mathcal{A}^{\mathcal{A}} you get the base A in mathscr and the exponent A in mathcal.

zauguin commented 6 months ago

This bug seems to remain unresolved. The above fix with the extra fontloader file does NOT work with StylisticSets

When trying the changed fontloader with NewComputerModern's ss01 it does work for me.

niruvt commented 6 months ago

When trying the changed fontloader with NewComputerModern's ss01 it does work for me.

Hello @zauguin,

How does one use the changed fontloader? Without using the fontloader, I provide a MWE:

\documentclass[border=1cm]{standalone}
\usepackage{fontspec}
\setmainfont[%
  Renderer          = {Harfbuzz},%
  StylisticSet      = {5},%
  CharacterVariant  = {5},%
  Extension         = {.otf}%
]{NewCM10-Book}

\begin{document}
x͜y\textsuperscript{x͜y}
\end{document}

image

My system is up-to-date. Can you reproduce this image with the fontloader?

niruvt commented 6 months ago

@zauguin, forgot to mention, for me, the following didn't work:

After adding file "fontloader-2023-08-19.lua" to the current directory, the output is correct:

In my log, I can see this, which means I am using the file, but the output is wrong:

luaotfload | init : Loading fontloader from absolute path "fontloader-2023-08-19.lua".
niruvt commented 6 months ago

Even with XeLaTeX, it fails:

image

zauguin commented 6 months ago

@niruvt This is an different issue. The font you are using has different optical sizes for 10pt and 8pt and the 10pt version does not seem to handle the combining character correctly here.

niruvt commented 6 months ago

@zauguin Okay, my bad.

zauguin commented 6 months ago

It's the same as the previous issue: The subscript is smaller and therefore uses a different font. If you only provide a updated NewCM10-Book and not an extended NewCM08-Book you will only affect the bigger one.

niruvt commented 6 months ago

@zauguin yes, I figured it out and hence deleted the comment, thanks for the attention!

antonis-tsolomitis commented 6 months ago

My system did not have the latest updates. After updating and after placing the above fontloader file in t he same directory NewCM produces correct output. So now the question is when will this be released? CTAN has a file with the same name but it is different than the one above.

zauguin commented 6 months ago

So now the question is when will this be released?

This is now merged into the dev branch and will probably be part of the next release.