Skip to content

Add loader for ufoLib2's JSON format - #426

Merged
cmyr merged 1 commit into
mainfrom
ufolib2-json
Oct 7, 2026
Merged

cmyr merged 1 commit into
mainfrom
ufolib2-json

Conversation

@cmyr

@cmyr cmyr commented Oct 6, 2026

Copy link
Copy Markdown
Member

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-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.

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.

@anthrotype anthrotype left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not at all slop :)

@cmyr
cmyr merged commit 148a0b1 into main Oct 7, 2026
5 checks passed
@cmyr
cmyr deleted the ufolib2-json branch October 7, 2026 16:20
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