Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
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
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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
208c5a5
to26c5e3f
CompareQuLogic approved these changesJun 19, 2020
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).
jkseppan approved these changesAug 4, 2020
6 tasks
Sign up for freeto 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.
Uh oh!
There was an error while loading.Please reload this page.
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