Skip to content

[WIP] Reverse font encoder#39

Open
lunakv wants to merge 10 commits into
photopea:gh-pagesfrom
lunakv:reverse
Open

[WIP] Reverse font encoder#39
lunakv wants to merge 10 commits into
photopea:gh-pagesfrom
lunakv:reverse

Conversation

@lunakv
Copy link
Copy Markdown

@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