-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Changes in SVG backend to improve compatibility with Affinity designer #28504
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Did you mean to close this? I noticed that tests were not passing, but were all failing in the same way, so not sure what the fix is, but it may be relatively easy to do, and we can do it within the same PR. |
Hi! Thanks for the message. I realized I read about the issue I was having in |
@@ -433,7 +432,7 @@ def test_mathtext_fallback_invalid(): | |||
@pytest.mark.parametrize( | |||
"fallback,fontlist", | |||
[("cm", ['DejaVu Sans', 'mpltest', 'STIXGeneral', 'cmr10', 'STIXGeneral']), | |||
("stix", ['DejaVu Sans', 'mpltest', 'STIXGeneral'])]) | |||
("stix", ['DejaVu Sans', 'mpltest', 'STIXGeneral', 'STIXGeneral', 'STIXGeneral'])]) |
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.
Why do we need the additional 'STIXGeneral' entries here?
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.
I have slightly changed the logic for how the tspan
s inside a text
tag are separated (backend_svg.py::_draw_text_as_text
line 1224 onwards).
During some testing I found poor compatibility with specifying multiple x
and y
in the same tspan
(from reading the docs maybe dx
would be better if the old way was to be preferred?)
My new solution is cleaner code-wise and seems to resolve the compatibility issues. However, it causes more tspans
to be generates, hence why the repetition in the tests.
To check we need to regenerate the svg files to make keep them in sync with our compare code, not because rendered output (in compliant viewers) actually changed? |
Exactly. That and because on the appveyor tests (and only there, azure and github were passung just fine) for some reason a few tests would fail with a very small RMS (~0.001) because of a few pixels in long ticklabels being slightly off when rendering (see attached example) |
The appeveyor failures look related and real. |
I had some time to debug the failing tests. It seems that the baseline images were specifying certain coordinates for |
Can you please rebase on main and squash all of the image updating into one commit? |
At some point we change from outputting a lot of digits to rounding to a smaller number of digits but did not bulk re-generate the test images because they were still passing. |
Should be done :) |
lib/matplotlib/font_manager.py
Outdated
@@ -266,8 +266,11 @@ def _get_fontconfig_fonts(): | |||
@lru_cache | |||
def _get_macos_fonts(): | |||
"""Cache and list the font paths known to ``system_profiler SPFontsDataType``.""" | |||
d, = plistlib.loads( | |||
subprocess.check_output(["system_profiler", "-xml", "SPFontsDataType"])) | |||
try: |
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.
Was this change supposed to be included?
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.
Apologies, that slipped in when squasing. Fixed now
It looks like there is still a merge from main in here? |
1f1b6e0
to
0e7f73d
Compare
Is this OK now? |
no, still a rouge merge from main...is your local main not equal to upstream main? |
…SVG._draw_text_as_path fixed linting (flake8 test failing) Fixed checks in testing for svg.fonttype = none fixed flake8 && failing tests linting modified tspans && fix to svg tests Updated baseline images for svg tests Update lib/matplotlib/testing/compare.py nicer regex to check if font syling in svg is specified Co-authored-by: Tim Hoffmann <[email protected]> Apply suggestions from code review More concise font testing in test_backend_svg.py Co-authored-by: Tim Hoffmann <[email protected]> Update lib/matplotlib/tests/test_mathtext.py Co-authored-by: Tim Hoffmann <[email protected]> Update backend_svg.py inlining `style` restored test images update to baseline images Fix to regex for testing/compare.py::compare forgot one baseline image
Gotcha! It is done now, I didn't realize I had to rebase, not merge upstream main. I was doing it though the nice green button on the github page, but that only offers the option to do a merge. |
Thank you for your work on this @LorenzoPeri17 . Congratulations on your first merged Matplotlib PR 🎉 I hope we hear from you again! |
Separate font attributes && use translate(x y) in RendererSVG._draw_text_as_path
PR summary
Closes #20910
Two small changes in the SVG backend:
xlink:href
tags' position is specified viatransform=translate(x y)
rather than withx
andy
attributestext
tags separatefont
attribute into its separate constituent propertiesPR checklist