mathtext: Fetch quad width & axis height from font metrics#31110
mathtext: Fetch quad width & axis height from font metrics#31110QuLogic wants to merge 3 commits intomatplotlib:text-overhaulfrom
Conversation
This mostly has a minimal change to results as the axis height is fairly closely aligned with the minus sign as previously implemented.
These are mostly wider than the previous calculation of the 'm' width. The values are invalid in the DejaVu fonts (-2048), so those still use the old method.
|
Re: DejaVu's font constants: I think you can't actually believe the values that fontforge gives you, because they appear to be nonstandard tables that I believe are "autofilled" by fontforge -- see https://fontforge.org/docs/techref/non-standard.html; also opening e.g. DejaVuSans.ttf with fontTools shows that there isn't actually a "TeX " table in that file (if I got that correctly). |
|
Doesn't it make sense to also add underline thickness and x-height while you are at it? For the LaTeX fonts and STIX, these should be very reliable, as LaTeX uses them. This only leaves DejaVu, for which one can measure the values once, and all other "custom" fonts, for which one can fall back to the old behavior. |
|
Probably we should do those as well, but maybe that should wait for the refactoring in #31121 as it makes it easier to fetch from the constants where necessary. |
|
It looks like 3 more images need to be updated. |
PR summary
As a followup to #31046 that @anntzer requested, this fetches the quad width and axis height from the font metrics, either the TFM or the TeX table in FontForge.
For Computer Modern and STIX, the axis height metric is very close to the previous calculation and there are minuscule changes. The quad width is a bit bigger than the old 'm' calculation, but it does appear closer to
usetex=Trueoutput.For DejaVu however, I'm not super happy with the embedded metrics. In #22852, @tfpf originally intended to calculate the axis height so that fraction bars aligned with the minus sign. This is not the case with the metric embedded in the font, and it's a pixel or two lower. Additionally, the quad space is completely bogus since it's -2048, so I didn't even bother adding it. I have left the axis height metric in for review here, but we may want to revert that for this font, especially since this is our default.
Note, I have based this PR on the
text-overhaul-figuresbranch so that the subsequent commits only show the relevant changes, but that does inflate the "Files changed" count.PR checklist