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 KernGroup type #725

Merged
merged 1 commit into from
Mar 7, 2024
Merged

Add KernGroup type #725

merged 1 commit into from
Mar 7, 2024

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Mar 6, 2024

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.

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}")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing the 2

@cmyr cmyr force-pushed the kern-group-type branch from 067bb64 to 794e62c Compare March 6, 2024 23:58
@cmyr cmyr mentioned this pull request Mar 6, 2024
KernSide::Side2 => "public.kern2.",
}
}
fn parse_kern_group(name: &str) -> Option<KernGroup> {
Copy link
Member

@anthrotype anthrotype Mar 7, 2024

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

Copy link
Member Author

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.

Copy link
Member

@anthrotype anthrotype left a 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.
@cmyr cmyr force-pushed the kern-group-type branch from 794e62c to 69dd5a5 Compare March 7, 2024 15:26
@cmyr cmyr added this pull request to the merge queue Mar 7, 2024
Merged via the queue into main with commit 98988d1 Mar 7, 2024
10 checks passed
@cmyr cmyr deleted the kern-group-type branch March 7, 2024 15:30
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.

3 participants