-
Notifications
You must be signed in to change notification settings - Fork 14
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
Unicode math improvements #67
Conversation
Ad 1 (no math families 2 and 3): OK |
Next release will be 1.04. I plan to do it in a week. |
Ok, but it seems like a weird choice. Not only because Considering that I also planned to address the fact, that OpTeX trick 0030, @olsak Is there other reason, except for backwards compatibility, for keeping the family number as 1? The next release will not be completely backwards compatible anyways, so this may be a rare chance to do more. |
Setting math families 2 and 3 doesn't do anything special for "new math fonts" See mlist.c:fixup_math_parameters in LuaTeX source: https://github.com/TeX-Live/luatex/blob/eee644d052c295920d378ef579a96fcca497af9a/source/texk/web2c/luatexdir/tex/mlist.c#L478
After any setting of `\Umathspaceafterscript` LuaTeX doesn't look at `\scriptspace`. The setting of `\Umathspaceafterscript` happens before `\_setunimathdimens` is called.
OK, I stil think that family number 0 would be better. But not making that change now. While messing with the Unicode math fonts I found other things addressed in the commits above:
Also more thing perhaps worth addressing:
The ConTeXt fontloader has the option to use those ratios to scale down the fonts automatically. The OpenType spec suggests values 80 and 60. It also mentions that when ssty font feature is used the font designer can assume these ratios are used. The |
Outlines for all optical sizes don't exist. See also olsak#7.
I am leaving this part to you @olsak. I don't feel like making decision about this. Some parts of documentation say that families 0..15 are reserved by OpTeX, other say that the user is free to use 5 and above. This is what I had before I gave up. diff --git a/optex/base/alloc.opm b/optex/base/alloc.opm
index 13252ca..aae5f67 100644
--- a/optex/base/alloc.opm
+++ b/optex/base/alloc.opm
@@ -28,7 +28,7 @@
\_countdef\_toksalloc=15 \_toksalloc=255
\_countdef\_readalloc=16 \_readalloc=-1
\_countdef\_writealloc=17 \_writealloc=-1
-\_countdef\_famalloc=18 \_famalloc=3
+\_countdef\_famalloc=18 \_famalloc=15 % 0..15 reserved
\_doc -----------------------------
The common allocation macro
diff --git a/optex/base/math-preload.opm b/optex/base/math-preload.opm
index 0ec9aba..3a60193 100644
--- a/optex/base/math-preload.opm
+++ b/optex/base/math-preload.opm
@@ -39,7 +39,6 @@
% \_setmathfamily 11 \_tenbi
\_setmathdimens
}
-\_count18=9 % families declared by \newfam are 12, 13, ...
\_def \normalmath {\_normalmath} \_def\boldmath {\_boldmath}
diff --git a/web/optex-tricks.html b/web/optex-tricks.html
index b23479e..715ce5c 100644
--- a/web/optex-tricks.html
+++ b/web/optex-tricks.html
@@ -1327,7 +1327,7 @@ macros follows:
\def\addUmathfont #1#2#3#4#5#6{% #1: fam (will be set), #2#3: normal font, #4#5: bold font
\ifx\_ncharrmA\undefined \errmessage{basic Unicode math font must be loaded first}\fi
- \global\advance \famaddress by1
+ \incr \famaddress
\global\chardef #1=\famaddress
\global\addto\_normalmath{\_corrmsize#6 \_loadumathfamily #1 {#2}{#3} }%
\ifx\relax#4\relax
@@ -1339,6 +1339,7 @@ macros follows:
\wterm{MATH-FONT: added #1=\the#1, normal: "#2", \ifx"#4"\else bold: "#4"\fi}
}
\newcount\famaddress \famaddress=100
+\chardef\_maifam = 100
</pre>
<p>The \addUmathfont has six parameters: |
Do you mean that we can read the data from OpenType math font and use it in the |
@olsak The ConTeXt font loader already reads the \initunifonts
\nopagenumbers
\tracingassigns=2
\def\test{%
\textfont 10=\text
\scriptfont 10=\script
\scriptscriptfont10=\scriptscript
%
$\fam10 {a_{\vrule b}}_{\vrule c}$
}
\font\text =file:firamath-regular.otf:mode=base;script=math;ssty=0 at 100pt
\font\script =file:firamath-regular.otf:mode=base;script=math;ssty=1 at 70pt
\font\scriptscript=file:firamath-regular.otf:mode=base;script=math;ssty=2 at 50pt
\test
%
%
\font\text =file:firamath-regular.otf:mode=base;script=math;ssty=0;mathsize=1 at 100pt
\font\script =file:firamath-regular.otf:mode=base;script=math;ssty=1;mathsize=2 at 100pt
\font\scriptscript=file:firamath-regular.otf:mode=base;script=math;ssty=2;mathsize=3 at 100pt
\test
\bye I used Fira Math for demonstration (it has I actually don't know how well these parameters are actually used/tested in LaTeX / ConTeXt and other OpenType Math systems. I couldn't find use of the font feature in proper ConTeXt (but it is very likely that I missed something) and didn't even look into LaTeX, nor XeTeX or MathJax how they deal with this. |
I have the following for use within OpTeX: --- a/optex/base/math-unicode.opm
+++ b/optex/base/math-unicode.opm
@@ -127,16 +127,15 @@
\_def\_mfontfeatures{mode=base;script=math;}
\_def\_loadumathfamily #1 #2#3 {%
- \_edef\_optsizesave{\_the\_optsize}%
- \_optsize=\_sizemtext \_font\_mF=\_umathname{#2}{\_textmff #3} at\_optsize
- \_textfont#1=\_mF
- \_optsize=\_sizemscript \_font\_mF=\_umathname{#2}{\_scriptmff #3} at\_optsize
- \_scriptfont#1=\_mF
- \_optsize=\_sizemsscript \_font\_mF=\_umathname{#2}{\_sscriptmff #3} at\_optsize
- \_scriptscriptfont#1=\_mF
- \_optsize=\_optsizesave \_ptmunit=\_ptunit
+ \_font\_mF=\_umathname{#2}{\_textmff #3} at\_sizemtext \_textfont #1=\_mF
+ \_font\_mF=\_umathname{#2}{\_scriptmff #3} at\_sizemtext \_scriptfont #1=\_mF
+ \_font\_mF=\_umathname{#2}{\_sscriptmff #3} at\_sizemtext \_scriptscriptfont#1=\_mF
}
-\_def\_textmff{ssty=0;} \_def\_scriptmff{ssty=1;} \_def\_sscriptmff{ssty=2;}
+% ssty: 0 = text, 1 = script, 2 = scriptscript
+% mathsize: 1 = text, 2 = script, 3 = scriptscript
+\_def\_textmff {ssty=0;mathsize=1;}
+\_def\_scriptmff {ssty=1;mathsize=2;}
+\_def\_sscriptmff{ssty=2;mathsize=3;}
\_doc -----------------------------
Unicode math font includes all typical math alphabets together, user needs not to Not sure what the |
While thesting the above, I also realized that the set Unicode math parameters are taken from the last set math family for said style. E.g. with
This doesn't seem desirable to me. Although the LuaTeX manual clearly documents this behaviour ("7.4.2 Font-based math parameters", this link should work now: https://www.pragma-ade.com/general/manuals/luatex.pdf#1031). Should we do something? @olsak LuaTeX seems to always set these parameters if it detects the font as a Unicode math font, that is, it has positive number of math parameters. We could define a font feature to |
Just to link this before I forget it again: https://www.tug.org/TUGboat/tb30-1/tb94vieth.pdf. Anyways, --- a/optex/base/math-unicode.opm
+++ b/optex/base/math-unicode.opm
@@ -71,7 +71,9 @@
\_cod -----------------------------
\_def\_normalunimath{%
+ \_dosetmathparams
\_loadumathfamily 1 {\_unimathfont}{} % Base font
+ \_nosetmathparams
\_loadmathfamily 4 rsfs % script
\_setunimathdimens
}%
@@ -124,7 +126,11 @@
\_cod -----------------------------
\_def\_umathname#1#2{"#1:\_mfontfeatures#2"}
-\_def\_mfontfeatures{mode=base;script=math;}
+\_def\_mfontfeatures{mode=base;script=math;\_mathparams}
+
+\_def\_dosetmathparams{\_glet\_mathparams=\_empty}
+\_def\_nosetmathparams{\_gdef\_mathparams{nomathparam;}}
+\_dosetmathparams
\_def\_loadumathfamily #1 #2#3 {%
\_font\_mF=\_umathname{#2}{\_textmff #3} at\_sizemtext \_textfont #1=\_mF |
Thank you for your ideas and examples. I will do more experiments before adopting a solution. |
Thank you, I added your ideas into master code. |
Too late, but I noticed that the ConTeXt generic code also defines font feature that should do this. So no need to depend on It is |
It seems that math |
Luaotfload had an update recently. I don't think it changed anything related recently, but there maybe is a change in the ConTeXt code. I'll be able to take a closer look in a few days. |
Setting math families 2 and 3 doesn't do anything special for "new math
fonts"
See mlist.c:fixup_math_parameters in LuaTeX source:
https://github.com/TeX-Live/luatex/blob/eee644d052c295920d378ef579a96fcca497af9a/source/texk/web2c/luatexdir/tex/mlist.c#L478
This allows shorter notation (i.e. 0 is implicit) when using
\Umathchardef
, etc.This would have also prevented the former bug in
\_setunimathdimens
which is executed before the\mathcode
for numbers are set:@olsak What is your plan on next release? I thought that with the amount of breaking changes in this release, we might be able to squeeze in more, so that there aren't several subsequent releases that break things. Possibly labeling the release 2.00, so that it is apparent that there are breaking changes?
Something else I also wanted to try are
\_pagedest
and\pgref
, and in the spirit of Unicode math only, fonts loaded with\initunifonts
only (no preloaded fonts).