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

Small changes to svg font embedding details#17669

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
jkseppan merged 2 commits intomatplotlib:masterfromanntzer:svgfont
Aug 4, 2020

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedJun 18, 2020
edited
Loading

PR Summary

1st commit: Switch svg glyph references back to hex; merge tex & non-tex names.

When embedding glyphs as paths in SVG files, each glyph has a name just
so that we can link to them when actually placing the glyphs.
Previously there were two different paths for non-usetex glyphs and
usetex glyphs.

  • Ina2287b1 I accidentally changed the number component of non-usetex
    names from hex to decimal (usetex was always using decimal); switch it
    back to hex as that's typically how glyph tables are listed anyways.
    Also switch the usetex case to hex for consistency.
  • Make non-usetex and usetex names use the same way to generate the
    name. The 2nd entry of ps_font_info typically matches postscript_name
    (but is only available for Type1 fonts, whereas postscript_name is
    defined for all fonts), but even if they donn't (see test_unicode_won),
    this doesn't matter as long as we are internally consistent...
    Also changed unicode_won test to actually parse the xml -- the regexp
    search seems quite slow locally, and anyways regex'ing xml is not
    necessarily a great idea :)

2nd commit: Record svg glyphs in 1/64 pixel units.

1/64-pixel is the "natural" unit for TrueType and FreeType ("F26Dot6").
Using it makes glyphs recorded in SVG files shorter, e.g.

M 88.796875 4.296875Q 88.796875 2.09375 87.140625 0.5Q 85.5 -1.09375 83.203125 -1.09375

becomes

M 1113 -72Q 709 -72 476 233Q 244 538 244 953

(the concatenated svg output of test_mathtext.py is ~10% shorter)
and easier to compare with FreeType values when troubleshooting font
embedding. An additionaltransform="scale(0.015625)" (i.e. 1/64) is
added at the end to scale the glyph, but given that a further scaling
and translation is done to actually render the glyph at the right size
and position in the svg, I doubt that this really affects svg renderer
performance (likely they can compose the two scalings first).

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

When embedding glyphs as paths in SVG files, each glyph has a name justso that we can link to them when actually placing the glyphs.Previously there were two different paths for non-usetex glyphs andusetex glyphs.- Ina2287b1 I accidentally changed the number component of non-usetex  names from hex to decimal (usetex was always using decimal); switch it  back to hex as that's typically how glyph tables are listed anyways.  Also switch the usetex case to hex for consistency.- Make non-usetex and usetex names use the same way to generate the  name.  The 2nd entry of ps_font_info typically matches postscript_name  (but is only available for Type1 fonts, whereas postscript_name is  defined for all fonts), but even if they donn't (see test_unicode_won),  this doesn't matter as long as we are internally consistent...  Also changed unicode_won test to actually parse the xml -- the regexp  search seems quite slow locally, and anyways regex'ing xml is not  necessarily a great idea :)
1/64-pixel is the "natural" unit for TrueType and FreeType ("F26Dot6").Using it makes glyphs recorded in SVG files shorter, e.g.```M 88.796875 4.296875Q 88.796875 2.09375 87.140625 0.5Q 85.5 -1.09375 83.203125 -1.09375```becomes```M 1113 -72Q 709 -72 476 233Q 244 538 244 953```(the concatenated svg output of test_mathtext.py is ~10% shorter)and easier to compare with FreeType values when troubleshooting fontembedding.  An additional `transform="scale(0.015625)"` (i.e. 1/64) isadded at the end to scale the glyph, but given that a further scalingand translation is done to actually render the glyph at the right sizeand position in the svg, I doubt that this really affects svg rendererperformance (likely they can compose the two scalings first).
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jkseppanjkseppanjkseppan approved these changes

@QuLogicQuLogicQuLogic approved these changes

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

Successfully merging this pull request may close these issues.

4 participants
@anntzer@jkseppan@QuLogic@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp