go-text / typesetting

High quality text shaping in pure Go.
Other
101 stars 10 forks source link

Fix leak if fonts are replaced in usage #48

Closed andydotxyz closed 1 year ago

andydotxyz commented 1 year ago

Move plan cache to the buffer object so we don't leak if the shaper / font is not needed any more

Fixes #47

benoitkugler commented 1 year ago

As a side note, I think it could make sense for Fyne to only create one Font object per byte slice, since it is a rather costly operation (like Gioui does). That would only reduce the leak, not remove it though, so this PR seems still required ;)

andydotxyz commented 1 year ago

As a side note, I think it could make sense for Fyne to only create one Font object per byte slice, since it is a rather costly operation (like Gioui does).

I agree, I thought Fyne basically did the same. The leak was when changing theme at which point we do need to read new font data.