Open dweymouth opened 1 month ago
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)
?
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.
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