unicode-math
unicode-math copied to clipboard
Application of ssty feature at different text sizes
If I understand the implementation correctly, right now unicode-math treats ssty as essentially a size feature: +ssty=1 is applied to maths smaller than \sf@size and +ssty=0 is applied to maths between \sf@size and \tf@size.
However, the relevant values of \sf@size and \tf@size are calculated only for the \normalsize of the document. That means that, e.g., primes will fail do display correctly if one writes \Large $ x' x'' x''' $. On the other hand if \setmathfont is issued after the size command, \sf@size and \tf@size are recalculated and the primes will display correctly (though problems will now arise at smaller sizes).
Here is an MWE:
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
$ x' x'' x''' $ vs. $ x\prime x\dprime x\trprime $
{\Large $ x' x'' x''' $ vs. $ x\prime x\dprime x\trprime $}
{\Large\setmathfont{Latin Modern Math} $ x' x'' x''' $ vs. $ x\prime x\dprime x\trprime $}
\end{document}
The comparison between the superscripted and unsuperscripted primes confirms that the ssty feature is at the root of the problem.
Is there a way to fix the application of ssty so that it is triggered if the expression is actually superscripted, as opposed to relying on size calculations?
Related issue report: #112.
I am not entirely sure whether applying +ssty=0 to font size larger than \g_@@_size_tfsf_fp or applying +ssty=1 to font size larger than \g_@@_size_sfssf_fp is appropriate. Despite the fact that these features are style features, I am inclined to treat them as size features, as I believe the design of these ssty glyphs is of optical size.
When in large font size (so large that the math script-script-size exceeds, say, 10pt), the math text-size, script-size and script-script-size should probably use Display, Subhead and Text anyway. This could be the case for Minion Math. If the math typeface does not contain the Display and/or Subhead fonts, then it is perfectly fine to use a scaled up Text font for all three levels of math. Forcing a wider, thicker version at large-size scripts just looks wrong to me.
I think I now agree and this was something that stalled me last time I started looking at this:

The first is \normalsize scaled up, and the second is \huge$...$ — the default in regular LaTeX is to not use optical scaling for subscripts/superscripts if the font is already large.
Achieving this in unicode-math needs a re-do of the way its font declarations interact with \DeclareMathSizes works, IIRC. Definitely not impossible but needs a bit of re-architecting rather than bug-fixing.
(If have to admit I'm still a little unsure about it all though.)
The first is
\normalsizescaled up, and the second is\huge$...$— the default in regular LaTeX is to not use optical scaling for subscripts/superscripts if the font is already large.
I apologize for not being word-perfect in English, but I disagree with the wording in the quoted comments. Here is my MWE to produce the side-by-side $a^{x^b}$ image:
% !TeX program = pdfLaTeX
\documentclass[10pt]{article}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}
\scalebox{2.074}{$a^{x^b}$} % \@xxpt / \@xpt
\huge$a^{x^b}$ % \newcommand\huge{\@setfontsize\huge\@xxpt{25}} for 10pt article
\end{document}
When using separate LM Math font files under pdfLaTeX, the already-large example on the right does use appropriate optical scaling, as the text-size (20.74pt) and script-size (14.518pt) fonts are taken from LMMathItalic12 while the script-script-size (10.37pt) font is taken from LMMathItalic10.
The limitation comes from OpenType LM Math which, as a single font file, provides only 3 optical sizes under XeLaTeX/LuaLaTeX. So, naturally, in the \huge$a^{x^b}$ case above I am inclined to argue that the scaled up version of 10pt design size should be used in all 3 math levels.
My point is: If the font is already large, then the default LaTeX still uses (well, tries to use) optical scaling (as the pdfLaTeX example illustrates). The reason that we observe only one design size in \huge via XeLaTeX/LuaLaTeX is due to the limitation of OpenType math font and the lack of Display and Subhead design sizes.
@RuixiZhang42 — you are correct, the apology should be mine. From the CM perspective optical scaling is being used, it's just not as extreme in the large case.
I agree ssty needs to be more specifically linked to size not style.