Small changes to svg font embedding details#17669
Merged
Merged
Conversation
208c5a5 to
26c5e3f
Compare
QuLogic
approved these changes
Jun 19, 2020
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. - In a2287b1 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.296875
Q 88.796875 2.09375 87.140625 0.5
Q 85.5 -1.09375 83.203125 -1.09375
```
becomes
```
M 1113 -72
Q 709 -72 476 233
Q 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 additional `transform="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).
jkseppan
approved these changes
Aug 4, 2020
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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