-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Type42 subsetting in PS/PDF #20391
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
Type42 subsetting in PS/PDF #20391
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
fc59f35
Proof of concept: Type42 subsetting in pdf
jkseppan a632b25
flake8
jkseppan 501b30e
Filter out just the py23 warning
jkseppan a5d527a
More flake8
jkseppan 8493184
Implement subsetting for PS backend
aitikgupta b61744b
Move getSubset to common pdf/ps backend
aitikgupta 4473942
Handle file-like objects instead of saving
aitikgupta 24219b9
Fix doc and warning
aitikgupta 525760e
Change function doc and context
aitikgupta 0d75117
Log the correct way
aitikgupta f5eebbb
Add fonttools min version for testing
aitikgupta 91417cd
Add fonttools in test workflow
aitikgupta aca3bb5
Use ASCII characters for logging
aitikgupta 265a563
Add unit test for get_glyphs_subset
aitikgupta 2193caa
Remove seek()
aitikgupta 5661f0d
Add prefix to subsetted font names according to PDF spec
aitikgupta d0d766f
Use charmap for prefix
aitikgupta 5ea7f1b
Update fonttools requirements
aitikgupta 17873f3
Drop PfEd table
aitikgupta 9837733
flush before reading the contents back from tmp file
aitikgupta f509731
Fix testing for subsetting
aitikgupta a362601
Add whatsnew entry for Type42 subsetting
aitikgupta 57267a3
Fix subset tests
aitikgupta 7571055
Add PS test for multiple fonttypes
aitikgupta 1630ad9
Use TemporaryDirectory instead of NamedTemporaryFile
aitikgupta fa197d2
Add fontTools in dependencies.rst
aitikgupta fe583dd
Add API changenote for new dependency
aitikgupta a95f2b6
Rebase tests.yml for packaging
aitikgupta 85f4377
Keep a reference to non-subsetted font for XObjects
aitikgupta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fontTools for type 42 subsetting | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
A new dependency known as `fontTools <https://fonttools.readthedocs.io/>`_ | ||
is integrated in with Maptlotlib 3.5 | ||
|
||
It is designed to be used with PS/EPS and PDF documents; and handles | ||
Type 42 font subsetting. |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Type 42 Subsetting is now enabled for PDF/PS backends | ||
----------------------------------------------------- | ||
|
||
`~matplotlib.backends.backend_pdf` and `~matplotlib.backends.backend_ps` now use | ||
a unified Type 42 font subsetting interface, with the help of `fontTools <https://fonttools.readthedocs.io/en/latest/>`_ | ||
|
||
Set `~matplotlib.RcParams`'s *fonttype* value as ``42`` to trigger this workflow: | ||
|
||
.. code-block:: | ||
|
||
# for PDF backend | ||
plt.rcParams['pdf.fonttype'] = 42 | ||
|
||
# for PS backend | ||
plt.rcParams['ps.fonttype'] = 42 | ||
|
||
|
||
fig, ax = plt.subplots() | ||
ax.text(0.4, 0.5, 'subsetted document is smaller in size!') | ||
|
||
fig.savefig("document.pdf") | ||
fig.savefig("document.ps") |
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ packaging==20.0 | |
pillow==6.2.0 | ||
pyparsing==2.2.1 | ||
python-dateutil==2.7 | ||
fonttools==4.22.0 |
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
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
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.