Skip to content

fix HintingCache with default variations#114

Open
Timbals wants to merge 1 commit intodfrg:mainfrom
Timbals:fix/hinting_cache
Open

fix HintingCache with default variations#114
Timbals wants to merge 1 commit intodfrg:mainfrom
Timbals:fix/hinting_cache

Conversation

@Timbals
Copy link
Copy Markdown

@Timbals Timbals commented Feb 27, 2026

skrifa will ignore the variation coordinates if they are all default values (googlefonts/fontations#1423). This broke the hinting cache because the coordinates from the skrifa HintingInstance were used to compare the cache key.

This PR stores copies of the size and coords in the cache entry instead of retrieving them from the HintingInstance.

Alternative: Could re-implement the effective_coords function (https://github.com/googlefonts/fontations/blob/d677a6bee28027a5d474bef20e0e6d156f7538a2/skrifa/src/instance.rs#L121-L127) and use those coords for the comparison, but any other changes to the size or coords of the HintingInstance would break the caching again, so I feel this is more robust.

Notably, cosmic-text will always include a default weight if the font supports it (since pop-os/cosmic-text#400) and will currently rebuild the hinting for every rasterized glyph due to this bug. This adds ~100µs per glyph for Roboto on my machine.

`skrifa` will ignore the variation coordinates if they are all default values. This broke the caching because the coordinates from the skrifa `HintingInstance` were used to compare the cache key.

This commit stores copies of the `size` and `coords` in the cache entry instead of retrieving them from the `HintingInstance`.
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.

1 participant