Skip to content

load ufoLib2's JSON wrapper for lib dates - #429

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

cmyr merged 1 commit into
mainfrom
ufolib2-json-dates

Conversation

@anthrotype

Copy link
Copy Markdown
Collaborator

ufoLib2 used to write plist dates in libs as bare ISO strings (and only with orjson; the stdlib json just raised TypeError), so the JSON loader got a string where Font::load gets a date.

fonttools/ufoLib2#463 (just merged) changed that to a wrapper like the one for binary data, {"type": "com.github.fonttools.ufoLib2.lib.plist.date", "date": "2020-01-02T03:04:05Z"}, where the string is the same as in a plist <date>.

This PR turns the wrapper back into a plist::Value::Date, with the same rules as the data wrapper: only an object with exactly the type and date keys counts as one (anything else stays a dictionary), and an invalid date is an error.

Bare strings written by older ufoLib2 versions still load as strings.

ufoLib2 now writes plist dates in libs as {"type":
"com.github.fonttools.ufoLib2.lib.plist.date", "date": <UTC string>}, using
the same string as a plist <date>. Turn it back into a plist::Value::Date,
like the data wrapper.
@anthrotype

Copy link
Copy Markdown
Collaborator Author

FWIW, I made a JSON schema for ufoLib2's JSON format: fonttools/ufoLib2#466. It includes the new date wrapper, and could be used to validate the test fixtures here (they do validate).

@cmyr cmyr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good!

@cmyr
cmyr merged commit c73ffc7 into main Oct 8, 2026
5 checks passed
@cmyr
cmyr deleted the ufolib2-json-dates branch October 8, 2026 12:59
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