8000 Add registry for custom table packer/unpacker classes by justvanrossum · Pull Request #2055 · fonttools/fonttools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add registry for custom table packer/unpacker classes #2055

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 6 commits into from
Sep 9, 2020

Conversation

justvanrossum
Copy link
Collaborator

Rationale:

  • Currently, all sfnt table packer/unpacker classes must live in fontTools.ttLib.tables
  • Sometimes a project can benefit from private table data, and would like to use the standard TTFont table API, without needing an explicit step to pack/unpack
  • Proposals for new OpenType tables would benefit from this, as experimentation can then easily be done without forking fonttools.

Implementation:

def registerCustomTableClass(tag, moduleName, className=None):
    """Register a custom packer/unpacker class for a table.
    The 'moduleName' must be an importable module. If no 'className'
    is given, it is derived from the tag, for example it will be
    table_C_U_S_T_ for a 'CUST' tag.
    """
    ...

I considered taking the simpler route by having the register function take a class object, but that would prevent lazy importing.

Copy link
Member
@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

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

that's very useful, thanks Just!

@justvanrossum justvanrossum merged commit 9064e53 into fonttools:master Sep 9, 2020
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.

2 participants
0