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

Improve font spec for SVG font referencing.#19253

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

Merged
jklymak merged 1 commit intomatplotlib:masterfromanntzer:svgfontspec
May 22, 2021

Conversation

anntzer
Copy link
Contributor

The 'font: ...' shorthand is much more concise than setting each
property separately: This replaces e.g.
"font-family:DejaVu Sans;font-size:12px;font-style:book;font-weight:book;"
by"font: 400 12px 'DejaVu Sans'".
Note that the previous font weight was plain wrong...

Also this revealed a bug in generate_css (we shouldn't run it through
escape_attrib, as quotes (e.g. around the font family name) get
mangled); and we don't need to load the font at all (we should just
report whatever font the user actually requested).

Split out of#19201, but also including the non-mathtext case.

PR Summary

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@QuLogic
Copy link
Member

Also this revealed a bug in generate_css (we shouldn't run it through
escape_attrib, as quotes (e.g. around the font family name) get
mangled); and we don't need to load the font at all (we should just
report whatever font the user actually requested).

But shouldn't they? The CSS goes in a<element> and thus a double quote must be escaped.

@anntzer
Copy link
ContributorAuthor

But the double quote would get escaped byXMLWriter.start when the XML is actually emitted; the point is that previously we were escaping it twice, both ingenerate_css and inXMLWriter.start.

@QuLogic
Copy link
Member

Yes, I didn't realize thatstart was inXMLWriter.

The 'font: ...' shorthand is much more concise than setting eachproperty separately: This replaces e.g.`"font-family:DejaVu Sans;font-size:12px;font-style:book;font-weight:book;"`by `"font: 400 12px 'DejaVu Sans'"`.Note that the previous font weight was plain wrong...Also this revealed a bug in generate_css (we shouldn't run it throughescape_attrib, as quotes (e.g. around the font family name) getmangled); and we don't need to load the font at all (we should justreport whatever font the user actually requested).
@jklymakjklymak merged commited32a04 intomatplotlib:masterMay 22, 2021
@anntzeranntzer deleted the svgfontspec branchMay 22, 2021 16:21
@QuLogicQuLogic added this to thev3.5.0 milestoneMay 25, 2021
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMar 28, 2024
We currently special-case the SVG converter depending on if it usedfonttype='none', and use one that has our base fonts available. However,this is not based on the rcParam setting (because we don't have that atconversion time), but on whether the SVG text contains the font styling[1]. This check for styling uses the _current_ version, which waschanged way back inmatplotlib#19253.These files were never re-generated though, and used the old version ofthe style, meaning the expected images never triggered the specialconverter. The result images are written with the current style, and_do_ trigger the special conveter.Evidentally, this never was a problem for most developers, becauseeveryone had DejaVu Sans installed globally, so the expected imagesmatched. However, on the clean macOS CI, it's not installed globally, sothe expected images get converted with the wrong font, and the testfails.[1]https://github.com/matplotlib/matplotlib/blob/de1102668dbc0694e98653bd17641e9d99394e57/lib/matplotlib/testing/compare.py#L303
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMar 28, 2024
We currently special-case the SVG converter depending on if it usedfonttype='none', and use one that has our base fonts available. However,this is not based on the rcParam setting (because we don't have that atconversion time), but on whether the SVG text contains the font styling[1]. This check for styling uses the _current_ version, which waschanged way back inmatplotlib#19253.These files were never re-generated though, and used the old version ofthe style, meaning the expected images never triggered the specialconverter. The result images are written with the current style, and_do_ trigger the special conveter.Evidentally, this never was a problem for most developers, becauseeveryone had DejaVu Sans installed globally, so the expected imagesmatched. However, on the clean macOS CI, it's not installed globally, sothe expected images get converted with the wrong font, and the testfails.[1]https://github.com/matplotlib/matplotlib/blob/de1102668dbc0694e98653bd17641e9d99394e57/lib/matplotlib/testing/compare.py#L303
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMar 28, 2024
We currently special-case the SVG converter depending on if it usedfonttype='none', and use one that has our base fonts available. However,this is not based on the rcParam setting (because we don't have that atconversion time), but on whether the SVG text contains the font styling[1]. This check for styling uses the _current_ version, which waschanged way back inmatplotlib#19253.These files were never re-generated though, and used the old version ofthe style, meaning the expected images never triggered the specialconverter. The result images are written with the current style, and_do_ trigger the special conveter.Evidentally, this never was a problem for most developers, becauseeveryone had DejaVu Sans installed globally, so the expected imagesmatched. However, on the clean macOS CI, it's not installed globally, sothe expected images get converted with the wrong font, and the testfails.[1]https://github.com/matplotlib/matplotlib/blob/de1102668dbc0694e98653bd17641e9d99394e57/lib/matplotlib/testing/compare.py#L303
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestMar 29, 2024
We currently special-case the SVG converter depending on if it usedfonttype='none', and use one that has our base fonts available. However,this is not based on the rcParam setting (because we don't have that atconversion time), but on whether the SVG text contains the font styling[1]. This check for styling uses the _current_ version, which waschanged way back inmatplotlib#19253.These files were never re-generated though, and used the old version ofthe style, meaning the expected images never triggered the specialconverter. The result images are written with the current style, and_do_ trigger the special conveter.Evidentally, this never was a problem for most developers, becauseeveryone had DejaVu Sans installed globally, so the expected imagesmatched. However, on the clean macOS CI, it's not installed globally, sothe expected images get converted with the wrong font, and the testfails.[1]https://github.com/matplotlib/matplotlib/blob/de1102668dbc0694e98653bd17641e9d99394e57/lib/matplotlib/testing/compare.py#L303
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@QuLogic@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp