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

Fix glyph cache crash #820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

InnocentusLime
Copy link
Contributor

Synopsis

Fixes #815. The Style::with_font method clones the received font and then changes it, placing a different atlas pointer in the cloned font. It, however, doesn't do anything with the characters field.

Because of that, if the original font caches more glyphs -- the font passed to Style::with_font ends up in an inconsistent state, which leads to either crashed or garbage looking graphics. This happens from very naive things like measuring text after construing a Style, so I think it's worth fixing.

The fix worked when I tested it against the example in issue #815.

The Fix

I simply modified the routine to supply the cloned font with its own characters map. To do this I also had to add a pub(crate) method for setting characters.

Alternatives

The alternative is to stop giving the cloned font a different atlas. But it looked like it might be against the original intention behind Style's design.

@KnorrFG
Copy link

KnorrFG commented Oct 10, 2024

Hey, I was wondering when this is getting merged. Are there any policies in place that prevent the merge?

@InnocentusLime
Copy link
Contributor Author

@not-fl3

Is there anything preventing the merge of this PR? 🤔

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.

Bug in the glyph caching system
2 participants