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

[propagate_anchors] detect component cycles, fix infinite loop #1023

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Aug 21, 2024

Fixes #1022

cyclical composites with infinite component depth are now correctly detected and skipped with a warning (they will probably just error out down the pipeline anyway).

We traverse the component trees in depth-first order while keeping track of the glyphs that we are currently visiting so we can detect cycles as they happen.

EDIT: I now copied @cmyr's solution from googlefonts/fontc#907
We now keep track of the composites that are waiting for their components as we process the queue, as well as the length of the queue at that point, and if we encounter the same glyph twice without the queue having gotten smaller it means we aren't making any more progress, thus we have a cycle.

Also, since we currently can only resolve component refs between master layers, for now we skip processing the other layers (fontc propagate_anchors.rs similarly only does master layers, see #1017).

just like fontc effectively does; at least until we implement proper support for dereferencing components from special layers
@anthrotype anthrotype force-pushed the fix-anchor-prop-infinite-loop branch from 19961ab to 75e8f7a Compare August 21, 2024 14:59
@anthrotype anthrotype force-pushed the fix-anchor-prop-infinite-loop branch from 75e8f7a to 6be3684 Compare August 21, 2024 15:01
@anthrotype anthrotype force-pushed the fix-anchor-prop-infinite-loop branch 2 times, most recently from 534b0c2 to ded266e Compare August 22, 2024 14:57
@anthrotype anthrotype force-pushed the fix-anchor-prop-infinite-loop branch from ded266e to 757841e Compare August 22, 2024 15:02
@anthrotype anthrotype merged commit 7041311 into main Aug 22, 2024
10 checks passed
@anthrotype anthrotype deleted the fix-anchor-prop-infinite-loop branch August 22, 2024 18:11
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.

new propagate_anchors may produce an infinite loop with cyclical component references
1 participant