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

It appears faceCache and metaCache in FontMap are never cleaned out nor is there an API to unload fonts #167

Open
dweymouth opened this issue Aug 5, 2024 · 2 comments

Comments

@dweymouth
Copy link

This means that if a (Fyne/Gio/etc) app uses a font once and doesn't need it anymore (ie it is not used within X minutes and we want to unload it), there is no way to unload the font from the app's memory space

@benoitkugler
Copy link
Contributor

Yes, that is correct. I guess we haven't thought of cases where you know for sure that you won't need a font in the future (perhaps for a language change, or as you mentioned it, based on a timer).
A rough workaround would be to change the FontMap entirely, but you would loose all the caching..

We should add some API to clear the FontMap, perhaps something like:
ClearCache(face *Face)
?

@dweymouth
Copy link
Author

I don't know what the naming should be, ClearCache sounds fine, or UnloadFace, or something similar. The idea at least for Fyne I think would be to eventually track when font faces were last used, and if they haven't been used in some minutes, unload/uncache them. For apps displaying arbitrary unicode strings coming from external content, it's often possible that a face is needed only to render a particular string, and then never again needed or not in a long while.

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

No branches or pull requests

2 participants