typesetting
typesetting copied to clipboard
Question: why is the default `HarfBuzzShaper` cache size 0?
Yesterday, I found that HarfBuzzShaper's cache size was 0 and NewFont was called every time different texts are rendered:
- https://github.com/hajimehoshi/guigui/issues/64
- https://github.com/hajimehoshi/ebiten/issues/3228
This issue could be prevented by settings some cache size. I was wondering why 0 is the initial value. Would it be possible to have initial cache size to avoid future troubles like me?
I guess the reason is that we do not have a constructor for HarfBuzzShaper and the zero value for the fontLRU cache has 0 as its maxSize.
I'm not sure there is an easy fix. Perhaps a better documentation could be enough ? (cc @whereswaldon )
I guess the reason is that we do not have a constructor for HarfBuzzShaper and the zero value for the fontLRU cache has 0 as its maxSize.
If this struct needs to have a non-zero cache by default, I'd have an integer member substracted by the default value so that the initial value (0) indicates the default value.
I actually thought about it, but what would SetCacheSize do then ? It would not do what the user expects
what would SetCacheSize do then ?
This function would update the member variable with the argument minus the default size.
what would SetCacheSize do then ?
This function would update the member variable with the argument minus the default size.
Ah of course ! 😅
I'm fine with adjusting the implementation to set a default cache size. I agree that size zero by default is a little silly.