fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.24k stars 1.4k forks source link

Custom fonts use memory that is never freed #4908

Open andydotxyz opened 5 months ago

andydotxyz commented 5 months ago

Checklist

Describe the bug

Set a font on Text.FontSource to display some text. Then remove this text. Memory is never cleared out of the font cache.

How to reproduce

As above

Screenshots

No response

Example code

    text1.FontSource, _ = fyne.LoadResourceFromPath("./WorkSans-Black.ttf")

Fyne version

v2.5.0-pre

Go compiler version

1.21

Operating system and version

all

Additional Information

No response

dweymouth commented 5 months ago

Just adding a note that this applies to fonts automatically loaded by Fyne from the OS too - although in this case it is bounded since at most one per Unicode script per style is loaded. When a fix for this is implemented we should make sure it covers the auto-loaded OS fonts that have not been used in awhile too.