Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Oct 3, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 28, 2020

... 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 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.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Member

@QuLogic QuLogic left a 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))
Copy link
Member

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?

Copy link
Contributor Author

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...

@anntzer
Copy link
Contributor Author

anntzer commented Sep 1, 2020

I also moved the bind defs to the global mpldict, which avoids having to repeat them for every font.

Copy link
Member

@timhoffm timhoffm left a 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.
@timhoffm timhoffm merged commit dd15dc0 into matplotlib:master Oct 3, 2020
@timhoffm timhoffm added this to the v3.4.0 milestone Oct 3, 2020
@anntzer anntzer deleted the unttps branch October 4, 2020 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants