Repository navigation
Add loader for ufoLib2's JSON format - #426
Merged
Merged
Conversation
ufoLib2 can dump a whole font to a single JSON document, which is much faster to load than a UFO directory. This adds Font::load_ufolib2_json and Font::from_ufolib2_json, behind a new `unstable-json` feature: this is not stable API, and may break in patch releases. The JSON is read into private types that mirror its shape and then converted, validating the same things as the .ufo path and reusing its object lib and groups handling (factored out of fontinfo and groups). The result is the same Font we get from loading the equivalent .ufo, apart from the gaps listed on from_ufolib2_json: metainfo and file names aren't in the format, and plist dates come through as strings. The fixtures in testdata/ufolib2_json are generated by ufoLib2, and the tests check that each loads to the same font as its .ufo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
100% slop, but behind a non-default feature. This has been tested against a large corpus, and loads the output of ufolib2 specifically, including lots of warts. Intended as a way for us to test gftools interp in fontc.
ufoLib2 can dump a whole font to a single JSON document, which is much faster to load than a UFO directory. This adds Font::load_ufolib2_json and Font::from_ufolib2_json, behind a new
unstable-jsonfeature: this is not stable API, and may break in patch releases.The JSON is read into private types that mirror its shape and then converted, validating the same things as the .ufo path and reusing its object lib and groups handling (factored out of fontinfo and groups). The result is the same Font we get from loading the equivalent .ufo, apart from the gaps listed on from_ufolib2_json: metainfo and file names aren't in the format, and plist dates come through as strings.
The fixtures in testdata/ufolib2_json are generated by ufoLib2, and the tests check that each loads to the same font as its .ufo.