Skip to content
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

[WIP] Reverse font encoder #39

Open
wants to merge 10 commits into
base: gh-pages
Choose a base branch
from
Open

Conversation

lunakv
Copy link

@lunakv lunakv commented Sep 16, 2021

This PR introduces a new class called Untypr that serves as the reverse to Typr; given a parsed JS font object, it serializes it back into an OTF font file.

The API consists of a single method: Untypr.encode(). It takes a font object as a parameter and returns an ArrayBuffer containing the resulting file. The font parameter is assumed to be in a format equivalent to the result of Typr.parse().

Because of this, the output is limited by which tables Typr supports. In addition to tables required by the OTF specification, Untypr is only able to include glyf, loca, kern, and SVG tables. Notably, it currently doesn't support the CFF table, neither for generation nor for reading. A font with data stored in the CFF table therefore can't be properly encoded by Untypr, because Untypr ignores the contents of that table.

There are a few other idiosyncrasies related to the format produced by Typr. For example, some fields are ignored and Untypr has to guess their value, and some data can become mangled in a way that cannot be recovered. These format-specific quirks and workarounds are annotated with a FIXME comment.

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.

1 participant