-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Implement de- and serialization for all fontinfo attributes #16
Conversation
Todo:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I think it's probably worth moving to a separate file as part of this PR? But I think that validation and serialization make sense to to separately.
I think I have to properly organize de/serializer code now. Also, need to parse guidelines into existing |
Okay, just ping me when you think this is ready! |
So, now all possible fields actually get deserialized in the test. What's needed next is custom types (e.g. OS2Panose, OS2FamilyClass, the WOFF dir attributes that should be an enum, etc.) plus custom de/serializers to perform validation. The |
Do Identifiers need their own |
Not sure I need all the |
Identifiers are annoying, I'm not sure how best to handle them. Probably yes, we should have a newtype and store them a s a string, but we should validate them on creation. |
Same for e.g.
So maybe both Tag and Identifier should be newtypes with a This reminds me that my Identifier verification is wrong. |
Hrm. There's some small stuff that needs validation, like various |
Yea, I think a validation function is totally reasonable. |
Went through the spec again at http://unifiedfontobject.org/versions/ufo3/fontinfo.plist/ and found some type discrepancies. Also changed some Todo comments, the spec does not mandate checks for some attributes. The spec is also somewhat lenient with types, declaring lots of stuff |
I'm happy either way with the aliases. |
I was just informed that the UFO spec is going to grow a minor version soon, 3.1, so that the glyph element can grow a verticalOrigin attribute in advance element. |
also the GLIF |
note to self:
|
Validation to come.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay some general thoughts but overall this looks good, thanks so much for taking it on!
I think it's worth merging this soon as a checkpoint, and then we can build out better error handling etc from there.
return Err(Error::FontInfoError); | ||
} | ||
|
||
if !(v[0..4].parse::<u16>().is_ok() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all these parse errors we could do something like, x.parse::<u8>().map_err(|_| Error::FontInfoError)?
It would need to be a newtype and validate on construction, too much work.
oh, one other suggestion here: run |
That was a lot of lints. Fixed them all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I haven't gone over all the latest changes closely, but I trust between you and clippy they make sense. I think this is a good time to get this merged, and then we can build from here.
I've added you as a collaborator to this repo; feel free to press the big green merge button when you think it's ready!
Edit: duh, needed to accept the invite. |
According to serde-rs/serde#1301 and serde-rs/serde#1444, easily de/serializing things with custom functions inside containers like Option is not possible, so you have to handle everything around it. Since fontinfo is quite expansive with more custom stuff (and de/serialization) to come, maybe it should move to its own module mid-term.