8000 [cffLib/psCharStrings] remove cffCtx, pass down isCFF2 by anthrotype · Pull Request #1007 · fonttools/fonttools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[cffLib/psCharStrings] remove cffCtx, pass down isCFF2 #1007

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
Jul 20, 2017

Conversation

anthrotype
Copy link
Member

As discussed in #968 (comment) and in private conversation with @behdad, here is an (admittedly huge) patch that should break the current deadlock, and allow us to keep backward compatibility with the old cffLib interface (so fontmake or robofont don't break).

  • Removed CFFContext
  • Added isCFF2 argument to CFFFontSet.decompile/compile, used from respective ttLib classes
  • Index classes get a isCFF2 argument in constructor (used for decompiling); must be True/False if file argument is not None; it is stored as self._isCFF2 to support lazy loading
  • Removed TopDictData class; reuse same TopDictIndexCompiler for both CFF and CFF2
  • CFFWriter and all *Compiler classes get an isCFF2 argument; defaults to the parent compiler's isCFF2 attribute
  • Removed size argument from produceItem method as unused and useless (len(data) is the same)
  • psCharStrings: removed useless ByteCodeBase class
  • A reference to the TopDict's VarStoreData is passed down to all the FontDicts' PrivateDict, so it can be used to get the number of regions while decompiling blend and vsindex operators

I know I should have broken this into smaller patches, but... 😬

/cc @readroberts

* Removed `CFFContext`
* Added `isCFF2` argument to CFFFontSet.decompile/compile, used from
  respective ttLib classes
* Index classes get a `isCFF2` argument in constructor (used for
  decompiling); must be True/False if `file` argument is not None;
  it is stored as self._isCFF2 to support lazy loading
* Removed `TopDictData` class; reuse same `TopDictIndexCompiler` for
  both CFF and CFF2
* `CFFWriter` and all `*Compiler` classes get an `isCFF2` argument;
  defaults to the parent compiler's `isCFF2` attribute
* Removed `size` argument from `produceItem` method as unused and
  useless (`len(data)` is the same)
* psCharStrings: removed useless ByteCodeBase class
* A reference to the TopDict's VarStoreData is passed down to all
  the FontDicts' PrivateDict, so it can be used to get the number of
  regions while decompiling blend and vsindex operators

See dicussion:
fonttools#968 (comment)
@anthrotype anthrotype requested review from behdad and miguelsousa July 19, 2017 17:58
@readroberts
Copy link
Collaborator

I was concerned after a conversation with Behdad today that a vsindex defined in a PrivateDict would not be inherited as the default vsindex by the charstrings which reference the PrivateDict, but I see that is not the case. Looks good to me.

@behdad
Copy link
Member
behdad commented Jul 20, 2017

Read,

FWIW, one reason we are removing the context is because it didn't work as you thought it does. Since some structs are loaded lazily, and the decompilation depends on isCFF2 bit of the context, you cannot load CFF, change the major version, and save as CFF2. That will confuse the lazy decompiler to think it should load CFF2 objects instead of CFF! Hence why we removed the context and always pass down isCFF2 during compile and decompile, separately.

@@ -2310,6 +2304,7 @@ def decompileAllCharStrings(self, progress):
progress.increment(0) # update
i = i + 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

i += 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or better yet, replace L2296-2297 with,

for i, charString in enumerate(self.CharStrings.values()):

and remove L2305.

Copy link
Member Author

Choose a reason for hiding this comment

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

@miguelsousa I think i'll leave that old piece of code like that for now. I'm actually tempted to deprecate the progress bar interface altogether. BTW, do you know if anybody is using that? /cc @justvanrossum

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not, and I doubt anyone is. If there's a safe way to deprecate it then I'm fine with that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not using it either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0