-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move PostScript Type3 subsetting to pure python. #18370
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
da4513e
to
1c0b4f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I understand PostScript, but this seems reasonable from what I read of the spec.
""".format(font_name=font.postscript_name, | ||
inv_units_per_em=1 / font.units_per_EM, | ||
bbox=" ".join(map(str, font.bbox)), | ||
encoding=" ".join("/{}".format(font.get_glyph_name(glyph_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this safe, or do you need to escape any Postscript special values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be safe per https://github.com/adobe-type-tools/agl-specification#6-assigning-glyph-names-in-new-fonts. We can always revisit if someone finds a font with a bad glyph name...
I also moved the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost dare approve based on my non-existing postscript knowledge, modulo a docstring that can at least give me an idea.
... similarly to the change for pdf, but easier because there are no baseline images for which we need to provide bug-level backcompat :-) Drop the FontInfo metadata (which is explicitly optional in the PostScript spec) to avoid having to figure out the correct encoding (which can be quite obscure). Replace the implementation of the `_sc` command from `7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse` to a plain `setcachedevice` (as I cannot see any case where the "other" branch is taken). Drop the splitting of long commands using `exec` (`_e`) -- this is only needed for level-1 postscript, which has a small fixed stack size; we output level-2 postscript (per backend_version) and I guess level-1 is rarely in use nowadays anyways (probably the feature could be added back if there's really demand for it, but let's not get ahead of ourselves). Previously, some composite characters would be output in a "compressed" form (e.g., accented characters would be recorded as "draw the accent, then run the charproc for the unaccented character"). This is lost, but I'd guess outputting .ps.gz is better if compression really matters.
... similarly to the change for pdf (#18181), but easier because there are no
baseline images for which we need to provide bug-level backcompat :-)
Drop the FontInfo metadata (which is explicitly optional in the
PostScript spec) to avoid having to figure out the correct encoding
(which can be quite obscure).
Replace the implementation of the
_sc
command from7 -1 roll{setcachedevice}{pop pop pop pop pop pop}ifelse
to a plainsetcachedevice
(as I cannot see any case where the "other" branch istaken).
Drop the splitting of long commands using
exec
(_e
) -- this is onlyneeded for level-1 postscript, which has a small fixed stack size; we
output level-2 postscript (per backend_version) and I guess level-1 is
rarely in use nowadays anyways (probably the feature could be added back
if there's really demand for it, but let's not get ahead of ourselves).
Previously, some composite characters would be output in a "compressed"
form (e.g., accented characters would be recorded as "draw the accent,
then run the charproc for the unaccented character"). This is lost, but
I'd guess outputting .ps.gz is better if compression really matters.
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
andpydocstyle<4
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).