Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Implement Type-1 decryption#20634
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Seems fine to me beyond the small minor points.
@@ -0,0 +1,8 @@ | |||
Type1Font objects now decrypt the encrypted part |
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 wonder if this should be an API note rather than whats-new. I'm not sure this is really a user-facing feature, even if it is public.
@staticmethod | ||
def _decrypt(ciphertext, key, ndiscard=4): | ||
""" | ||
Decrypt ciphertext using the Type-1 font algorithm |
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 there a reference to the "encryption" we can add here? Also is decrypt the right word? Its really just obfuscated at this point?
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.
The reference is the manual referenced in the file docstring. The manual uses the words "encrypt" and "decrypt", so I think it is best to follow its terminology.
Could we consider defering most of type1's handling to fonttools as well instead? |
I tried - its type-1 implementation is very incomplete and not sufficient for subsetting. |
OK then. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Just some minor points, please address them (or explicitly reject them if you don't want to make the changes), then this can be self-merged.
With this I can produce smaller pdf files with usetex in some smalltests, but this obviously needs more extensive testing, thus markingas draft.On top ofmatplotlib#20634 andmatplotlib#20715.Closesmatplotlib#127.
Thanks for the review@anntzer - I made the changes. I'll wait for the CI to complete before merging. |
@jkseppan if one of us doesn't get to it, feel free to self-merge when CI is all green. |
Uh oh!
There was an error while loading.Please reload this page.
This is a prerequisite of subsetting.
The zeros at the end are not needed by our implementation so don'tcrash if there are too few.Always pass an even number of bytes to unhexlify.
With this I can produce smaller pdf files with usetex in some smalltests, but this obviously needs more extensive testing, thus markingas draft.On top ofmatplotlib#20634 andmatplotlib#20715.Closesmatplotlib#127.
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Implement decryption of the encrypted part of Type-1 fonts. This is a prerequisite of subsetting (#127) although that will need a lot more code.
I looked at using fonttools for Type-1 subsetting, but it seems to lack much of the functionality needed for that, although it does implement this decryption algorithm. (The code in this PR is completely my own implementation.)
cc@aitikgupta - subsetting TTF fonts is more important than Type-1 since it affects a lot more users, but if you want to take a look at Type-1 subsetting, this is the first step
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
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).