Hello,

I use fallbacks to substitute "Arabic" digits in math to Indic ones. The
mechanism doesn't work in the newest context. I tried it with mkxl version
in 2025.02.04 17:52 in a clean install. The email is a bit long, but please
bear with me, so I can learn a few other things along the way.

Compiling type-imp-mathdigits.mkiv (provided in the distribution) does not
change the digits to Indic form.

This is the part after the typescript definition:

\usetypescript [mathdigits] [xits-dejavu] [extendedarabicindic]
> \setupbodyfont[dejavu]
> \starttext
>     $3+2=5 \quad \bf 3+2=5$
> \stoptext


The logs contain the following, which shows dejavusansmono is not loaded.

mkiv lua stats  > loaded fonts: 3 files: texgyredejavu-math.otf,
> dejavuserif-bold.ttf, dejavuserif.ttf


IIUC one issue is that setupbodyfont kind of undoes the usetypescript
command because dejavu typescripts already define MathRoman.

Could you also explain the difference between setupbodyfont and
switchtobodyfont? Do I need the latter?

If I use the following instead, the Arabic digits do turn into Indic ones.

\usetypescript [mathdigits] [xits-dejavu] [extendedarabicindic]
> \setupbodyfont[dejavu]
> \definefontsynonym[MathRoman][MathRomanBold][fallbacks=mathdigits]
> \switchtobodyfont[sans]


With some caveats:
1) This still ignores the MathRoman definition in the above typescript (if
I change the above to use euler, e.g., I see no change).
2) This only changes MathRoman and not MathRomanBold. So if I have
something like {\bf $2+3$}, then the fallback does not kick in.
3) I can't use
\definefontsynonym[MathRoman][MathRoman][fallbacks=mathdigits] because it
creates a loop. Is there a way to "deep copy" font definitions (rather than
the "copy by reference") we have here? That way, I could run the fallback
for both MathRoman and MathRomanBold.

Speaking of which, what's the difference between \definefont and
\definefontsynonym?

What happens when either of these appear within a typescript definition? Is
the only difference, that within typescripts we have a separate namespace
to which the Sans, Serif, MathRoman, etc. are attached? Can I access the
MathRoman defined within typescript MyTypescript as "MyTypescriptMathRoman"
or something like that? What about if I define BaseMath (a non-standard
name, other than Sans, SansBold, MathRoman, etc.)? Are these also attached
to that namespace?

What is typescriptcollection BTW? Is it only cosmetic? Or can we pull in
all definitions from a collection? Does it have to be the same as the file
name?

What's the difference between MathRoman and MathRomanBold? I thought when
we would automatically get the Bold, Italic, BoldItalic variants when we
define something like Sans. Or do we need to pull in some setups for that?
For math, it seems that MathRoman has all the bold glyphs inside (at the
digitsbold offset). Does it also have the bold version of other symbols?
Then, what's the use of MathRomanBold?

In the math typescripts, I see the feature "math\mathsizesuffix"? Is it for
normal, script, scriptscript size? Who sets this macro? Are the math
typescripts loaded multiple times with different \mathsizesuffix values? At
what time?

Back to the original question, if I switch usetypescript and setupbodyfont
(see below), I see the math font changes taking effect (e.g., by picking up
euler-math.otf instead of xits-math.otf). However, the fallback still
doesn't work.

\setupbodyfont[dejavu]
> \usetypescript [mathdigits] [xits-dejavu] [extendedarabicindic]
> %\definefontsynonym[MathRoman][MathRomanBold][fallbacks=mathdigits]
> \switchtobodyfont[sans,20pt]


I need to uncomment the third line above to get the fallbacks to work. I
feel that the digitsnormal in MathRomanBold (used in the fallback) is
slightly bolder than the normal one, but my eyes may be failing me :)

Now it gets more mysterious. See this code snippet:

% no change from mathdigits file
> \starttypescript [mathdigits] [dejavu] [arabicindic,extendedarabicindic]
> \resetfontfallback  [mathdigits]
> \definefontfallback [mathdigits] [dejavusansmono]
> [digits\typescriptthree] [check=yes,force=yes,offset=digitsnormal]
> \definefontfallback [mathdigits] [dejavusansmonobold]
> [digits\typescriptthree] [check=yes,force=yes,offset=digitsbold]
> \stoptypescript



\starttypescript [mathdigits] [xits-dejavu]
> [arabicindic,extendedarabicindic]
> \usetypescript [mathdigits] [dejavu] [\typescriptthree]
> \definefontsynonym[MathRoman]
> [file:xits-math.otf][features=math\mathsizesuffix,goodies=xits-math,fallbacks=mathdigits]
> % copied from comments of the same file
> \definefontsynonym[MathRomanDigitsXitsDejavu]
> [file:xits-math.otf][features=math\mathsizesuffix,goodies=xits-math,fallbacks=mathdigits]
> \stoptypescript



\setupbodyfont[dejavu]
> \usetypescript [mathdigits] [xits-dejavu] [extendedarabicindic]
> % copied essentially from comments of the same file
> \definefontsynonym [MathRoman] [MathRomanDigitsXitsDejavu]
> \switchtobodyfont[sans,20pt]



\starttext
>     $3+2=5 \quad \bf 3+2=5$ math with fallback\\
>     {\bf$3+2=5 \quad \bf 3+2=5$ bold math}\\
>     {۳ + ۲ = ۵ \bf ۳ + ۲ = ۵ text Indic digits}\\
>     {3 + 2 = 5 \bf 3 + 2 = 5 text Arabic diigts}\\
>     %$$\sum_{i=1}^{8} x^2 = \pi\alpha + e^{-\beta}$$
> \stoptext


If the last line is uncommented, I ran into the following error.

Sorry, but I can't typeset math unless various parameters have been set.
This is
normally done by loading special math fonts into the math family slots.
Your font
set is lacking at least the parameter mentioned earlier.

When it's commented, the fallbacks still don't happen, even if I rewrite
the last definition as \definefontsynonym [MathRoman]
[MathRomanDigitsXitsDejavu][fallbacks=mathdigits].

In some other tests (not with math), I noticed that in fallback definition,
I also need to set the target key to be the same as the second parameter of
the definition; something like:

\definefontfallback [mathdigits] [dejavusansmono] [digitsarabicindic]
> [check=yes,force=yes,offset=digitsnormal,target=digitsarabicindic]


But I don't have a MWE for it right now.

Thanks a lot for your help,
Mohammad
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to