Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale option doesn't fully work with LuaLaTeX #287

Closed
eg9 opened this issue Mar 10, 2015 · 8 comments
Closed

Scale option doesn't fully work with LuaLaTeX #287

eg9 opened this issue Mar 10, 2015 · 8 comments

Comments

@eg9
Copy link
Contributor

eg9 commented Mar 10, 2015

Consider the following example

\documentclass{article}

\usepackage{unicode-math}
\setmathfont[Scale=2.8]{latinmodern-math.otf}

\begin{document}

\[\nu_e + \beta^+\]

\end{document}

The placement of the superscript is incorrect with LuaLaTeX, while it is correct with XeLaTeX. The box is shifted by -3.62994pt with LuaLaTeX, by -10.16402pt with XeLaTeX, meaning that the scaling is not applied to the relevant parameter.

Subscripts are OK (however, XeLaTeX seems to be using a larger shifting down, but it's another matter).

See http://tex.stackexchange.com/questions/232320/superscript-placement-using-unicode-math-with-scaling for reference.

@eg9
Copy link
Contributor Author

eg9 commented Jan 21, 2019

The issue now also appear with XeLaTeX.

@RuixiZhang42
Copy link

As of 2019/01/21, with the newest unicode-math in the working branch (v0.8m), the above MWE produces wrong outputs under both engines:

luax

Problem analysis

During my test toward latex3/fontspec#349, I realized where this problem came from. The legacy font dimensions’ setups for families 2 and 3 are wrong, because they are simply based on Scale=1.00001 and Scale=0.99999.

Thus, technically only the math font with Scale=1 are “truly” setup correctly. For those who uses Scale=MatchLowercase or Scale=MatchUppercase, this problem is not noticeable because those scaling factors are likely to be around 1.

Possible solution

If I changed Scale=1.00001 and Scale=0.99999 in um-code-main.dtx to Scale=2.800028 and Scale=2.799972, respectively, I got the following outputs, which seem to be correct:

luaa

Therefore, loading the same OpenType math font for the second and the third times should use scale factors which look like the following:

Scale=1.00001 * <user specified scale> % for family 2

and

Scale=0.99999 * <user specified scale> % for family 3

@wspr
Copy link
Collaborator

wspr commented Jan 21, 2019 via email

@wspr
Copy link
Collaborator

wspr commented Jan 21, 2019 via email

@RuixiZhang42
Copy link

RuixiZhang42 commented Jan 21, 2019

@wspr To be honest, I do not like the new scaling idea, because I think it will cause unnecessary confusion. A “cumulative” scale doesn’t sound right (to me at least). If a new key were to be introduced, I would suggest CompoundScale as in “compound interest”, which implies that the operation is multiplicative.

I do like the current “override”-style method of Scale as I believe it’s clearer. After all, it is unicode-math that needs to load a single math font thrice, so we are really just dealing with a unicode-math problem.

I also thought about an “additive” approach rather than a “multiplicative” one, i.e.,

<user scale> ± ε   v.s.   <user scale> * ( 1 ± ε )

Any thoughts?

@wspr
Copy link
Collaborator

wspr commented Jan 23, 2019

I didn't go with the additive scale largely because I didn't think having two approaches would be that useful. (Personally I think additive works better for something in absolute units like "fontsize = fontsize +2pt".)

And although I really liked CompoundScale as a name I went with ScaleAgain as it struck me as I was implementing the feature; I thought it would be memorable and the name captures exactly what it's doing :)

wspr added a commit that referenced this issue Jan 26, 2019
thanks again for the bug & analysis

closes #287
@RuixiZhang42
Copy link

RuixiZhang42 commented Jan 26, 2019

Maybe the internal TeX rounding error won’t be a problem, but I think it’s worth mentioning here before the next release. Consider the following example:

\documentclass{article}
\usepackage{unicode-math}

\newcommand*\temp{0.7}% Play around with scale here

\setmainfont{texgyrepagella-regular.otf}[Scale=\temp]
\setmathfont{texgyrepagella-math.otf}[Scale=\temp]
\begin{document}
$\mathstrut$%
\the\numexpr\fontdimen6\font\par
\the\numexpr\fontdimen6\textfont2, family~2\par
\the\numexpr\fontdimen6\textfont3, family~3
\end{document}

which shows that families 2 and 3 are loaded at 458760sp and 458750sp, where the size of family 3 coincides with the text font 458750sp. Similar issue may appear under different “principle” scaling factors:

Scale 0.7 0.8 0.9 1.0 1.1 1.2
text em 458750 524290 589820 655360 720900 786430
family 2 em 458760 524290 (?) 589830 655370 720900 (?) 786440
family 3 em 458750 (?) 524280 589820 (?) 655350 720890 786420

I hope this will not cause any real problem as TeX forbids loading the same font at the same scale more than once.

On another note, Scale=MatchLowercase and Scale=MatchUppercase usually result in non-simple fraction scaling factors, so the em’s are likely to be truly different.

@RuixiZhang42
Copy link

BTW, the log file says that s*[<final scale>] are indeed different, so maybe the font is being loaded differently after all. It’s just that the em’s happen to be not distinguishable.

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

No branches or pull requests

3 participants