Skip to content

Invalidate buffer cache when fonts are loaded#3352

Open
airstrike wants to merge 1 commit into
iced-rs:masterfrom
airstrike:fix/font-cache
Open

Invalidate buffer cache when fonts are loaded#3352
airstrike wants to merge 1 commit into
iced-rs:masterfrom
airstrike:fix/font-cache

Conversation

@airstrike

Copy link
Copy Markdown
Contributor

The text BufferCache keys on (content, font, size, ...) but does not account for fonts loaded after a buffer is first shaped, because it assumes all fonts are loaded at startup.

As a result, a buffer using a given missing font but shaped with a fallback font would persist in the cache even after said font was loaded, because the key hash hadn't changed.

Fix: pass the FontSystem version into Cache::allocate so when the version advances after a font is loaded, the cache is invalidated and buffers are reshaped correctly with the right font.

The text BufferCache keys on (content, font, size, ...) but does not account
for fonts loaded after a buffer is first shaped, because it assumes all fonts
are loaded at startup.

As a result, a buffer using a given missing font but shaped with a fallback
font would persist in the cache even after said font was loaded, because the
key hash hadn't changed.

Fix: pass the FontSystem version into `Cache::allocate` so when the
version advances after a font is loaded, the cache is invalidated
and buffers are reshaped correctly with the right font.
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