Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new class called
Untypr
that serves as the reverse toTypr
; 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 anArrayBuffer
containing the resulting file. The font parameter is assumed to be in a format equivalent to the result ofTypr.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 includeglyf
,loca
,kern
, andSVG
tables. Notably, it currently doesn't support theCFF
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.