Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
anntzer wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromanntzer:mathtext-glyphs

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedSep 25, 2019
edited
Loading

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

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@QuLogic
Copy link
Member

So would this fix the weird uneven baseline that seems to happen in some (all?) mathtext test images?

@anntzer
Copy link
ContributorAuthor

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is this correct?

@jklymak
Copy link
Member

jklymak commentedSep 25, 2019
edited
Loading

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?

@anntzer
Copy link
ContributorAuthor

Yes, I need to write up something...

@anntzer
Copy link
ContributorAuthor

anntzer commentedNov 5, 2020
edited
Loading

This also mostly fixes#18899, but the example at#18899 actually shows that the glyphs are also cut in the horizontal direction:
hdpi
The bottom left corner of thex and the right edges of the digits (using mathtext) are clearly cut with this PR :/

I think another problem is that draw_text_to_bitmap doesn't support subpixel positioning, there seems to be some story related tosub_offset at the C level and old commits from@mdboom mentioning links with the wiggly baseline problem...

@github-actions
Copy link

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.

@github-actionsgithub-actionsbot added the status: inactiveMarked by the “Stale” Github Action labelJun 26, 2023
@anntzer
Copy link
ContributorAuthor

Should likely be kept and put in in some form once the baseline image machinery is revamped.

@anntzeranntzer added keepItems to be ignored by the “Stale” Github Action and removed status: inactiveMarked by the “Stale” Github Action labelsJun 26, 2023
@anntzeranntzer mentioned this pull requestAug 7, 2023
5 tasks
@anntzeranntzer mentioned this pull requestApr 27, 2025
5 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
keepItems to be ignored by the “Stale” Github Actionstatus: needs rebasetopic: text/mathtext
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

star (*) symbol in text box cuts off bottom of text when saved
3 participants
@anntzer@QuLogic@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp