Skip to content
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

Add a basic designspace parser #272

Merged
merged 10 commits into from
Nov 12, 2022
Merged

Add a basic designspace parser #272

merged 10 commits into from
Nov 12, 2022

Conversation

rsheeter
Copy link
Collaborator

@rsheeter rsheeter commented Nov 10, 2022

Intended for use by Rust compiler so it can use norad to read designspace+ufo(s) to produce IR.

Serde xml seems slightly limited in ability to do things like flatten pointless container elements. If we want more control we might need to parse w/o using it.

src/designspace.rs Outdated Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
src/designspace.rs Outdated Show resolved Hide resolved
@madig
Copy link
Collaborator

madig commented Nov 10, 2022

(Will have a look later. Did you take inspiration from https://github.com/simoncozens/rust-font-tools/blob/main/designspace/src/lib.rs?)

@madig
Copy link
Collaborator

madig commented Nov 10, 2022

Ah, you may want to rebase this on #274 because it got a newer quick-xml.

@rsheeter rsheeter mentioned this pull request Nov 11, 2022
@rsheeter rsheeter marked this pull request as ready for review November 11, 2022 04:39
@rsheeter rsheeter changed the title [WIP] Parse designspace files Add a basic designspace parser Nov 11, 2022
src/designspace.rs Outdated Show resolved Hide resolved
src/designspace.rs Outdated Show resolved Hide resolved
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Overall looks good, fairly straight-forward. I do think the API would be improved by removing the wrapper types. One possible pattern I see to handle something like this, while still leveraging derive, is to have a private MyTypeSerdeRepr type that is designed to work with serde, and then you deserialize that and then convert it into your actual type? Not sure if this would make sense here but it's one idea. Otherwise there are various other ways to do custom deserialize.

src/designspace.rs Outdated Show resolved Hide resolved
src/designspace.rs Show resolved Hide resolved
/// The maximum value for a continuous axis, in user space coordinates.
pub maximum: Option<f32>,
/// The possible values for a discrete axis, in user space coordinates.
pub values: Option<Vec<f32>>,
Copy link
Member

Choose a reason for hiding this comment

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

do we want to distinguish between a None and an empty vec?

Copy link
Collaborator Author

@rsheeter rsheeter Nov 12, 2022

Choose a reason for hiding this comment

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

I wish there was a way to write Option<NonEmptyVec>.

src/designspace.rs Show resolved Hide resolved
src/designspace.rs Outdated Show resolved Hide resolved
@dfrg dfrg merged commit c546de8 into linebender:master Nov 12, 2022
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.

6 participants