mathtext: add mathnormal and distinguish between normal and italic family #31121
+373
−52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR summary
This adds
\mathnormalto the mathtext parser and handlesmathitandmathnormal/default differently, to replicate the behaviour of LaTeX. In particular,itproduces italic digits, whereasnormalproduces upright digits.closes #29253
This is implemented as follows:
For
cm, add thecmti(Computer Modern Text Italic) and use it forit. Usecmmifornormal, but map digits tocmr(same as in LaTeX). Technically, LaTeX further distinguishes betweennormaland the default, where the default uses roman digits andnormaluses the digits from cmmi, which are slightly offset.For
stixanddejavu, 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
PR checklist