FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Move PostScript Type3 subsetting to pure python. by anntzer · Pull Request #18370 · matplotlib/matplotlib · GitHub

Repository navigation

Move PostScript Type3 subsetting to pure python. - #18370

Merged
timhoffm merged 1 commit into
matplotlib:masterfrom
anntzer:unttps
Oct 3, 2020
Merged

timhoffm merged 1 commit into
matplotlib:masterfrom
anntzer:unttps

Conversation

anntzer commented Aug 28, 2020 •
edited
Loading

Copy link
Copy Markdown
Contributor

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

QuLogic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can't say I understand PostScript, but this seems reasonable from what I read of the spec.

Comment thread lib/matplotlib/backends/backend_ps.py Outdated
""".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
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this safe, or do you need to escape any Postscript special values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Comment thread lib/matplotlib/tests/test_backend_ps.py Outdated

anntzer commented Sep 1, 2020

Copy link
Copy Markdown
Contributor Author

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

timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 merged commit dd15dc0 into matplotlib:master Oct 3, 2020
timhoffm added this to the v3.4.0 milestone Oct 3, 2020
anntzer deleted the unttps branch October 4, 2020 07:06
QuLogic mentioned this pull request Mar 18, 2021
5 tasks done
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL