Small changes to svg font embedding details #17669
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
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.
becomes
(the concatenated svg output of test_mathtext.py is ~10% shorter)
and easier to compare with FreeType values when troubleshooting font
embedding. An additional
transform="scale(0.015625)"
(i.e. 1/64) isadded 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