-
Notifications
You must be signed in to change notification settings - Fork 29
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
Inappropriate scriptsize/scriptscriptsize range calculation #510
Comments
Somewhere near Section 4.2 Script and scriptscript fonts/features, I think the following additions in the documentation would be great:
I hope the above additions will address #275, #478 and this issue at once. |
Here is a more “visual” example: \documentclass{ctexart}
\usepackage{unicode-math}
\setmathfont{Fira Math}[
script-font = TeX Gyre Pagella Math,
sscript-font = TeX Gyre Termes Math
]
\begin{document}
$E_{E_E} 2_{2_2}$
\end{document} I was expecting |
Thanks, that’s a good example. I hadn’t overlooked this, I just don’t have much time at the moment… I really appreciate the work you’ve done to work through the issue!
|
It seems that this issue shows the reason of #503. I tried to change |
If we use font size command as \documentclass{article}
\usepackage{amsmath,unicode-math}
\setmathfont{XITS Math}
\def\TAG#1{\tag*{\scriptsize\ttfamily\textbackslash#1}}
\begin{document}
{\tiny \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{tiny} \]}
{\scriptsize \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{scriptsize} \]}
{\footnotesize \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{footnotesize} \]}
{\small \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{small} \]}
{\normalsize \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{normalsize} \]}
{\large \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{large} \]}
{\Large \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{Large} \]}
{\LARGE \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{LARGE} \]}
{\huge \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{huge} \]}
{\Huge \[ ab^{ab^{ab}} + f'(x) + g_{x_y}(x) \TAG{Huge} \]}
\end{document} IMHO, script/scriptscript font should not based on the absolute font size. |
This is indeed a controversial problem. In #275 Will and I had a discussion on whether the But I also acknowledge that by doing so (i.e., “size”-linked) we are breaking The current issue points out that
An easy fix for now, without changing font information, is to issue \DeclareMathSizes{10}{10}{8}{6}% article
...
\DeclareMathSizes{10.5bp}{10.5bp}{8.4bp}{6.3bp}% ctex article
... before If |
I have modified the Note that "Unicode subscripts and superscripts" are smaller than the "TeX" sub/superscripts, so decreasing (The fonts shown above are Latin Modern, Fira, XITS and Cambria) |
I'm a little confused here. The code to select a maths font is currently:
where the "trial font" is supposed to load the maths font for the first time, extract values of the different sizes, then use Is this not what happens? As the explanation of the problem and the proposed fix implies that doesn't happen. |
@wspr Apparently not, I’m afraid… With the following example: \documentclass{article}
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
\begin{document}
$E_{E_E}$\par
\makeatletter
\f@size\par\sf@size\par\ssf@size
\makeatother
\end{document} I see that the target sizes are set up correctly at Package fontspec Info: Font family 'texgyrepagella-math.otf(0)' created for
(fontspec) font 'texgyrepagella-math.otf' with options
(fontspec) [BoldItalicFont={},ItalicFont={},SmallCapsFont={},Script
=Math].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <->"[texgyrepagella-math.otf]/OT:script=math;language=DF
LT;"
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
Package fontspec Info: Font family 'texgyrepagella-math.otf(1)' created for
(fontspec) font 'texgyrepagella-math.otf' with options
(fontspec) [BoldItalicFont={},ItalicFont={},SmallCapsFont={},Script
=Math,SizeFeatures={{Size=8.5-},{Size=6-8.5,Font=texgyrepagella-math.otf,Style=
MathScript},{Size=-6,Font=texgyrepagella-math.otf,Style=MathScriptScript}}].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <8.5->"[texgyrepagella-math.otf]/OT:script=math;language
=DFLT;"<6-8.5>"[texgyrepagella-math.otf]/OT:script=math;language=DFLT;+ssty=0;"
<-6>"[texgyrepagella-math.otf]/OT:script=math;language=DFLT;+ssty=1;"
(fontspec) - 'small caps' (m/sc) with NFSS spec.: Although the order of |
@wspr Wow, I think I finally figure something out. Please ignore the “fix” in the OP — it was written before I was aware of the order of I modified \__um_cs_new:Nn \__um_declare_math_sizes:
{
\dim_compare:nF { \fontdimen 10 \g__um_trial_font == 0pt }
{
\DeclareMathSizes { \f@size } { \f@size }
{ \__um_fontdimen_to_scale:nN {10} \g__um_trial_font }
{ \__um_fontdimen_to_scale:nN {11} \g__um_trial_font }
\__um_warning:n
{
\fp_eval:n { \__um_fontdimen_to_scale:nN {11} \g__um_trial_font }
\space versus\space \ssf@size\space !!!
}
}
} I then compiled the example in my previous comment and got this message: ! LaTeX3 Error: Unknown message '5.5 versus 5 !!!' for module 'unicode-math'. So I realized that the new sizes were not updated until the first formula was encountered. A reasonable fix, based on 32.2 Math fonts setup of \cs_new:Nn \@@_declare_math_sizes:
{
\dim_compare:nF { \fontdimen 10 \g_@@_trial_font == 0pt }
{
\DeclareMathSizes { \f@size } { \f@size }
{ \@@_fontdimen_to_scale:nN {10} \g_@@_trial_font }
{ \@@_fontdimen_to_scale:nN {11} \g_@@_trial_font }
\check@mathfonts
}
} which forces the sizes of the math font to be updated. Though there will be additional messages in the log: LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7.4> on input line 4.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5.5> on input line 4. |
Wow, of course! That was a pretty big oversight of mine… thanks so much for digging into this, I really appreciate it.
So the next question is “what is correct?” I still think that by default the maths font setup should respect the design of the font, but it would be nice to provide an interface for the class designer.
I don’t have much time tonight but I’ll put in the quick fix straight away...
|
I don't have time to debug now but unfortunately the |
Too bad that However, there was an overlooked issue in the original code — I didn’t check whether With a non-math font in \dim_compare:nTF { \fontdimen 10 \g_@@_trial_font == 0pt }
{
\fp_gset:Nn \g_@@_size_tfsf_fp { (\f@size +\sf@size )/2 }
\fp_gset:Nn \g_@@_size_sfssf_fp { (\sf@size+\ssf@size)/2 }
}
{
\fp_gset:Nn \g_@@_size_tfsf_fp { (\f@size +\@@_sf_size: )/2 }
\fp_gset:Nn \g_@@_size_sfssf_fp { (\@@_sf_size:+\@@_ssf_size:)/2 }
} |
… or something better — to define |
I hadn’t thought of that, but luckily my code is smarter than I am!
I assume that any maths font with a `math` OpenType script will always be “well defined”, so if \setmathfont is called on a non-math font, it bypasses the \DeclareMathSizes line:
\bool_if:NT \g_@@_init_bool \@@_fontspec_trial_font:
\bool_if:NT \g_@@_init_bool \@@_declare_math_sizes:
So hopefully we’re good here :)
|
For some reasons, after the initial trial fails, \documentclass{article}
\usepackage{unicode-math}
\setmathfont{texgyretermes-regular.otf} % non-math font
\begin{document}
$E_{E_E}$
\end{document} In the log: Package fontspec Warning: Font "texgyretermes-regular" does not contain
(fontspec) requested Script "Math".
Package fontspec Info: Font family 'texgyretermes-regular.otf(0)' created for
...
Package fontspec Info: Font family 'texgyretermes-regular.otf(1)' created for
(fontspec) font 'texgyretermes-regular.otf' with options
(fontspec) [BoldItalicFont={},ItalicFont={},SmallCapsFont={},Script
=Math,SizeFeatures={{Size=5-},{Size=0-5,Font=texgyretermes-regular.otf,Style=Ma
thScript},{Size=-0,Font=texgyretermes-regular.otf,Style=MathScriptScript}}].
... In particular, the |
Loading a non-math font like this is no longer supported and produces warning:
Package unicode-math Warning: The first font loaded by unicode-math must be an
(unicode-math) OpenType Math font (with script=math). If you
(unicode-math) simply want ‘the default’ before loading
(unicode-math) supplementary fonts over the top for certain
(unicode-math) ranges, use:
(unicode-math) \setmathfont{latinmodern-math.otf}
And the side-effect is that latin modern math is loaded anyway, which (I think) overwrites the funny size for texgyretermes.
I should possibly make that warning an error...
|
Ah yes, |
Description
The ranges for applying different
ssty
features are IMHO calculated inappropriately. More specifically, the calculation relies on class declaration\DeclareMathSizes
but this declaration will be overwritten later. This leads to inconsistency and sometimes incorrect results.Check/indicate
Minimal example demonstrating the issue
Further details
I choose the
ctexart
class and the Fira Math font specifically for this issue. The default\normalsize
ofctexart
is10.5bp = 10.539375pt
, and there is a class declaration of the following form:According to
unicode-math
:+ssty=1
is applied to sizes-6
, since(5 + 7)/2
;+ssty=0
is applied to sizes6-8.769685
, since(7 + 10.539375)/2
;8.769685-
.But the problem is that Fira Math has
ScriptScriptPercentScaleDown = 60
. Sounicode-math
will eventually load the second-level subscript at10.539375pt * 0.6 = 6.323625pt
, to which first-level subscript optical size is applied.Perhaps instead of
We should consider
P.S. Fira Math does not contain optical sizes yet (firamath/firamath#23) but the current issue stands.
The text was updated successfully, but these errors were encountered: