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

Support for vector hrule rendering#26337

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
devRD wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromdevRD:mt-hrulerender

Conversation

devRD
Copy link
Contributor

PR summary

Fixes#23763

The current generated images are:

[PNG]
Hrule_at_bottom

[SVG]
Hrule_at_bottom

PR checklist

@QuLogic
Copy link
Member

QuLogic commentedJul 26, 2023
edited
Loading

After some discussion in our GSoC meeting, this is probably the reverse of the way to fix the issue. It appears that the raster output is shifted up when it shouldn't be (i.e., if it's a regular fraction, then all text is on the baseline, but with the test case from#23763,all text is moved up (disregarding the missing shift for the patched fraction.)) The vector output remains on the baseline for both versions.

@devRD
Copy link
ContributorAuthor

Possibly, the raster output needs the correct width, height, and depth to view a similar output to the vector image. The current dimensions for vector are given as:

w,h,d=map(
np.ceil, [self.box.width,self.box.height,self.box.depth])

Applying the same calculations to the raster gives the following output, which is still shifted upwards and cuts off the end of the denominator text.

Hrule.pngHrule.svg
Hrule_at_bottomHrule_at_bottom

A few pointers from the above images:

  1. The fraction appears to be askew as well compared to theusetex=True version and could be related toissue #18389
  2. Thethickness of theHrule seems to be different than the TeX version.
  3. The fraction gets misaligned from the center of the= sign.

The raster output being cut off might be caused due to theshifted calculation:

# Ideally, we could just use self.glyphs and self.rects here, shifting
# their coordinates by (-xmin, -ymin), but this yields slightly
# different results due to floating point slop; shipping twice is the
# old approach and keeps baseline images backcompat.
shifted=ship(self.box, (-xmin,-ymin))
antialiased=mpl.rcParams['text.antialiased']
forox,oy,infoinshifted.glyphs:

So updatingfor ox, oy, info in shifted.glyphs: to fetchox,oy fromself.glyphs kind of fixes the issue here.

Hrule.pngHrule.svg
Hrule_at_bottomHrule_at_bottom

I also tinkered around with the_genfrac function to check whether removing additional spacing improves the alignment of the images when rendering fractions.

Vbox(0,thickness*2.0),# space

which does improve the fraction spacing a bit, but the output shift betweenpng andsvg seems to stay put.

Hrule.pngHrule.svg
Hrule_at_bottomHrule_at_bottom

@devRD
Copy link
ContributorAuthor

@anntzer@oscargus Any insights on how to proceed with this?

@devRD
Copy link
ContributorAuthor

Additionally, with the above edits the#23763 example ofhrule rendering, theHrule seems to disappear completely in the raster output.

Hrule.pngHrule.svg
Hrule_at_bottomHrule_at_bottom

@anntzer
Copy link
Contributor

I'll have limited access to a dev machine for a few days, but can look into it after.

@anntzer
Copy link
Contributor

I haven't looked in depth into what's happening here, but 1) skipping the int-casting (via np.ceil) for vector output would seem normal, but can (likely?) cause shifts wrt. raster output; 2) perhaps#15339 (comment) and (the last part of)#15339 (comment) may be relevant?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]: Inconsistent rendering between backends when rendering Mathtext horizontal rule
4 participants
@devRD@QuLogic@anntzer@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp