Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix positioning of mathtext glyphs#15339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
So would this fix the weird uneven baseline that seems to happen in some (all?) mathtext test images? |
Not right now, but I have a plan... Basically the origin of the uneven baselines, I think, is that draw_glyph_to_bitmap specifies thetop right corner of the glyph, but that can be a fractional value (FreeType gives glyph sizes in (1/64)px) and then there is some roundoff when actually copying the glyph outline to the FT2Image which leads to the baseline being unaligned. I think best would be to fix the mathtext logic to position glyphs by baseline/right position and adjust draw_glyph_to_bitmap accordingly; alternatively we can "reverse-engineer" the values that need to be sent to draw_glyph_to_bitmap to fix that roundoff. |
for x1, y1, x2, y2 in self._rects: | ||
x1 += dxmin | ||
x2 += dymin | ||
y1 += dxmin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is this correct?
jklymak commentedSep 25, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I was just digging through this code in an attempt to understand#15313. If you are thinking about it all and understand it, can you add a few comments for posterity? |
Yes, I need to write up something... |
anntzer commentedNov 5, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This also mostly fixes#18899, but the example at#18899 actually shows that the glyphs are also cut in the horizontal direction: I think another problem is that draw_text_to_bitmap doesn't support subpixel positioning, there seems to be some story related to |
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
Should likely be kept and put in in some form once the baseline image machinery is revamped. |
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Fixes#15313 by porting mplcairo's mathtext backend to matplotlib. Also breaks all mathtext image comparison tests due to subpixel positioning issues :( Some of them should be fixed on this PR, but others are issues with the old mathtext code.
Will do some more detailed writeup at some later time...
PR Checklist