Skip to content

[glyphs] Handle RTL kerning#1570

Merged
cmyr merged 2 commits into
mainfrom
glyphs-kern-rtl
Jul 22, 2025
Merged

[glyphs] Handle RTL kerning#1570
cmyr merged 2 commits into
mainfrom
glyphs-kern-rtl

Conversation

@cmyr

@cmyr cmyr commented Jul 18, 2025

Copy link
Copy Markdown
Member

This matches glyphsLib, which just converts these into LTR kerning rules.

Base automatically changed from glyphs-cleanup-kern to main July 21, 2025 14:01
Comment thread glyphs2fontir/src/source.rs Outdated
}
}

#[allow(clippy::type_complexity)] // it's not _that_ bad

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have generally chosen to fix these. A type alias for the rather ugly map type seems like it would do it.

I would expect get_kerning to merely fetch, it's a bit weird for it to take a Cow and modify things. It's also deviating from the intended behavior that kerning is done, we're just fetching it at this point. Is there a reason we can't do this earlier such that get_kerning remains just a lookup?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added some docs explaining what's going on.

assert!(bad_kerns.is_empty(), "{bad_kerns:#?}");
}

// helpers:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment isn't helpful.

Why isn't parse_side impl From<&str> for KernSide (since it's infallible)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is just a helper used in tests, not sure there's any clear advantage to having a From impl since it wouldn't ever be used anywhere else.

Comment thread glyphs2fontir/src/source.rs Outdated
}

font_info.font.kerning_ltr.get(our_id)
fn flip_class_side(s: &SmolStr) -> SmolStr {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if introducing a type (enum? there seem to be distinct cases) for kerning identifier and hanging some of this stuff off it would work out nicely?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We turn this into an enum later, when we're actually generating the IR; this is about making the pre-IR RTL kerns look like the pre-IR RTL kerns.

Comment thread glyphs2fontir/src/source.rs Outdated
Comment thread glyphs2fontir/src/source.rs

@rsheeter rsheeter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Broadly LGTM, though I hope we can avoid the get_kerning makes changes aspect by altering where the work is done.

@cmyr cmyr force-pushed the glyphs-kern-rtl branch from ea5c135 to 7f88991 Compare July 22, 2025 18:21
cmyr added 2 commits July 22, 2025 14:55
This matches glyphsLib, which just converts these into LTR kerning
rules.
@cmyr cmyr force-pushed the glyphs-kern-rtl branch from 7f88991 to aa8f07e Compare July 22, 2025 18:55
@cmyr cmyr added this pull request to the merge queue Jul 22, 2025
Merged via the queue into main with commit a10f4ed Jul 22, 2025
12 checks passed
@cmyr cmyr deleted the glyphs-kern-rtl branch July 22, 2025 18: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