-
Notifications
You must be signed in to change notification settings - Fork 15
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 KernGroup type #725
Add KernGroup type #725
Conversation
fontir/src/ir.rs
Outdated
s.strip_prefix("side1.") | ||
.map(|s| KernGroup::Side1(s.into())) | ||
.or_else(|| s.strip_prefix("side2.").map(|s| KernGroup::Side2(s.into()))) | ||
.ok_or_else(|| D::Error::custom(format!("missing side1/side prefix: {s}"))) |
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.
Missing the 2
KernSide::Side2 => "public.kern2.", | ||
} | ||
} | ||
fn parse_kern_group(name: &str) -> Option<KernGroup> { |
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.
(optional) could this be a method on KernGroup maybe? KernGroup::parse
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.
the issue is that the parsing behaviour depends on the backend, so it doesn't make sense to hang it off the common type.
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.
LGTM
This encodes in the type system the idea that kerning groups have an associated side, instead of having this be encoded as a prefix on a string. This removes the need to hae separate `KernSide` enums, and removes possible complications around using the same type for glyph names and group names.
This encodes in the type system the idea that kerning groups have an associated side, instead of having this be encoded as a prefix on a string.
This removes the need to hae separate
KernSide
enums, and removes possible complications around using the same type for glyph names and group names.I was expecting this to be a smaller diff, but overall I think it's at least a modest improvement.