| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
We would need a test here, and I think a What's new note for the new math normal option would be good as well.
Can you link to where you obtained the font files? They do not match what I have in my TexLive installation, but there may be some version mismatch.
Sorry, something went wrong.
|
Thanks for your comments.
Will do. I did not add tests yet, because a lot of tests where failing with the text-overaul branch at the time.
I got them from https://ctan.org/tex-archive/fonts/cm/ps-type1/bakoma. |
Sorry, something went wrong.
|
@QuLogic it looks like the tests are still failing with the text-overhaul branch here. Do you know a workaround? It is a bit difficult to pinpoint the tests that I need to update, when everything fails. |
Sorry, something went wrong.
|
It's a bit complicated; you would have to fetch from the text-overhaul-figures branch, then test against those, and commit only the new ones, if any. Of course, if you're only adding a new test, then that is simpler as you can just add it here directly. However, at the moment, that branch is a bit out of sync with text-overhaul as I'm preparing to merge #31107. If you do update the test images yourself, please keep it as a separate commit so that it can be stripped before merging. |
Sorry, something went wrong.
|
Thanks a lot. |
Sorry, something went wrong.
|
The branches should be in sync again. |
Sorry, something went wrong.
|
Taking a quick look at the results, I see in mathfont_cm_10, the mathbf does now look bolder, and in mathfont_cm_20, the mathtt is now fixed-width. Additionally, items like \mathbb are now upright by default; I would have to check if that matches LaTeX though. There does seem to be something wrong with \mathit though, as in mathfont_cm_{15,16,17} it appears that DejaVu Sans is being used instead of an italic Computer Modern. |
Sorry, something went wrong.
Thanks for testing. Previously, the BakomaFonts class would force all digits (no matter what font was selected) to rm (cmr10) via the latex_to_bakoma lookup table. This would only happen for cm and was not consistent with the other font classes and with LaTeX (https://www.overleaf.com/learn/latex/Mathematical_fonts#Other_mathematical_fonts), although I am not entirely sure if this replicates some ancient version of LaTeX. mathfont_cm_{15,16,17} looks correct on my end. It looks like cmti to me, as it should. That said, some other tests still fail here, like mathtext_cm_00. The letters are displayed upright instead of italic in mathnormal mode. There seems to be a logic bug in the other classes. I'll do some debugging. |
Sorry, something went wrong.
This is likely due to an outdated local font cache, which does not include cmti10. rm ~/.cache/matplotlib/fontlist* prior to running the tests fixed this for me. |
Sorry, something went wrong.
|
I fixed all of the regressions that I could find. There are still a large number of the computer modern tests failing, which I cannot quite put my finger on. |
Sorry, something went wrong.
Ah right, I forgot it doesn't update for the internal fonts. You can bump the __version__ in FontManager to force an update. |
Sorry, something went wrong.
|
Some of the remaining test failures with Computer Modern seem to come from metrics being measured on cmti instead of cmmi. One example is _make_space, which measures the width of the 'm' glyph from the 'it' family (which has changed). There are more subtle places, though. |
Sorry, something went wrong.
|
The tests succeed now against the baseline images from QuLogic's branch, except for those few cases that are expected to fail due to the changed behaviour. The previous failures were caused by the slanted attribute not being set correctly for fontname = normal font in the BakomaFonts class, causing the kerning do be slightly off. |
Sorry, something went wrong.
|
I have updated the announcement to be more vocal about the changed behaviour of mathtext.default: it. |
Sorry, something went wrong.
|
Some tests would be nice (you can maybe use check_figures_equal to compare a mathnormal string and the corresponding mixture of mathrm & mathit, not so much to save a few baseline images but more importantly because that would actually test the semantics of mathnormal). |
Sorry, something went wrong.
Both 'normal' (via default math) and 'it' are already covered by the existing tests. A test for explicit \mathnormal is still missing. I'll try to add a test the way you propose. Note that we cannot compare mathnormal with mathit even for letters, because they can be different fonts/alphabets (for example in the case of computer modern). |
Sorry, something went wrong.
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.
|
I have just rebased the branch against text-overhaul and resolved the merge conflicts due to #31110 being merged. Is there anything else that needs doing? |
Sorry, something went wrong.
You need to do this when adding new internal fonts. After clearing the cache, I see 14 test changes. For Computer Modern, we get mathit working as well as mathbf, mathtt and mathsf. But I see that mathbf+mathsf (test 57) doesn't get bold; is there a way to fix that one? For DejaVu Sans/Serif and STIX, these are tests 15&18 where mathit is now really italic. However, it seems that STIX Sans doesn't also get fixed? |
Sorry, something went wrong.
|
Thanks for your feedback!
Done.
I expect these 14. stixsans: Unfortunately, sans-serif italic digits are not defined as unicode symbols (see https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols#Digits) nor in Stix 1. So we have to fall back to sans-serif upright here. A general remark: Combining two environments such as mathbf + mathsf is unique to the hard-coded Stix implementation and is realized via font_class. Neither classic LaTeX nor lualatex (with or without unicode-math) support this -- they simply use the innermost environment. The modern way in lualatex with unicode-math would be a \mathsfbf environment, but that is something for a future PR. |
Sorry, something went wrong.
There was a problem hiding this comment.
Preferably, you could squash the FontManager bump into the commit that adds the new fonts as well.
Sorry, something went wrong.
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.
Ensure that \mathnormal is parsed and sets digits upright.
mathtext: add mathnormal and distinguish between normal and italic family
This includes images changes for the following pull requests / commits: * [Fix center of rotation with rotation_mode='anchor'](matplotlib#29199) (c44db77) * [Remove ttconv backwards-compatibility code](matplotlib#30145) (8caff88) * [Remove kerning_factor from tests](matplotlib#29816) (7b4d725) * [Set text hinting to defaults](matplotlib#29816) (8255ae2) * [Update FreeType to 2.13.3](matplotlib#29816) (89c054d) * [Implement text shaping with libraqm](matplotlib#30000) (b0ded3a, 9813523) * [Add language parameter to Text objects](matplotlib#29794) (7ce8eae) * [Fix auto-sized glyphs with BaKoMa fonts](matplotlib#29936) (3ba2c13) * [pdf: Improve text with characters outside embedded font limits](matplotlib#30512) (b70fb88, 6cedcf7) * [Prepare `CharacterTracker` for advanced font features](matplotlib#30608) (8274e17, 70dc388, df670cf, ed5e074) * [Add font feature API to Text](matplotlib#29695) (972a688) * [Fix spacing in r"$\max f$"](matplotlib#30715) (4a99a83) * [Implement libraqm for vector outputs](matplotlib#30607) (bd17cd4) * [Drop the FT2Font intermediate buffer](matplotlib#30059) (9d7d7b4) * [Rasterize dvi files without dvipng](matplotlib#30039) (7627118) * [Update bundled FreeType and HarfBuzz libraries](matplotlib#30938) (a161658, 9619bcc) * [Fix positioning of wide mathtext accents](matplotlib#31069) (c2fa7ba) * [Refactor RendererAgg.draw_{mathtext,text,tex} to use same base algorithm](matplotlib#31085) (931bcf3) * [Implement TeX's fraction and script alignment](matplotlib#31046) (94ff452, 4bfa0f9, 1cd8510) * [Fix confusion between text height and ascent in metrics calculations](matplotlib#31107) (60f2310) * [mathtext: Fetch quad width & axis height from font metrics](matplotlib#31110) (692df3f, 383028b) * [mathtext: add mathnormal and distinguish between normal and italic family](matplotlib#31121) (a6913f3) * [ENH: Ignore empty text for tightbbox](matplotlib#31285) (d772043) * [Drop axis_artist tickdir image compat, due to text-overhaul merge](matplotlib#31281) (2057583) * [text: Use font metrics to determine line heights](matplotlib#31291) (3ab6a27, d961462, 97f4943) * [ps/pdf: Override font height metrics to support AFM files](matplotlib#31371) (e0913d4) * [TST: Cleanup back-compat code in tests touched by text overhaul](matplotlib#31295) (7c33379) * [TST: Set tests touched by text overhaul to mpl20 style](matplotlib#31300) (41c4d8d)
| Back | FazBrowse Home | New Git URL |
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
PR checklist