Skip to content

Conversation

@llohse
Copy link

@llohse llohse commented Feb 9, 2026

PR summary

This adds \mathnormal to the mathtext parser and handles mathit and mathnormal/default differently, to replicate the behaviour of LaTeX. In particular, it produces italic digits, whereas normal produces upright digits.

closes #29253

This is implemented as follows:
For cm, add the cmti (Computer Modern Text Italic) and use it for it. Use cmmi for normal, but map digits to cmr (same as in LaTeX). Technically, LaTeX further distinguishes between normal and the default, where the default uses roman digits and normal uses the digits from cmmi, which are slightly offset.

For stix and dejavu, the font for digits is mapped to either upright or italic for normal and it, respesctively.

To facilitate these features, I have moved the _get_font_constants functionality into the respective font classes instead of a global lookup table. This gets rid of the non-local access to the private _get_fonts from the lookup table. Moreover, this change prepares for reading the constants dynamically, as is necessary with generic OpenType math fonts.
If this change is controversial, I could try to work around it.

@QuLogic I have filed the PR against the text-overhaul branch because of the massive changes therein with respect to main.

Examples

cm stix

PR checklist

Replace lookup table for font constants based on the family name
by methods in their respective classes.

Removes non-local call of private _get_font method in
_get_font_constant_set.

This simplifies implementing dynamically loaded font constants.
To replicate LaTeX behaviour, distinguish between "italic" and "normal"
math. In particular, digits should be set italic in the \mathit env.

For `cm`, use cmti font for "it"
For general UnicodeFont (stix, DejaVu, ...), maps digits to roman or
italic alphabet, depending on "normal" or "it" environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant