playcanvas / engine

JavaScript game engine built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.69k stars 1.36k forks source link

Add a 'reset' API for Canvas Font #2570

Open yaustar opened 3 years ago

yaustar commented 3 years ago

Add a 'reset' to canvas font so that it removes the current 'cache' of characters and textures to keep VRAM usage low.

During a long session, there may be an accumulation of textures that could be cleared out.

vkalpias commented 3 years ago

Is that different from destroying and recreating the canvas font? There is already a destroy function.

willeastcott commented 3 years ago

The CanvasFont API needs a full overhaul, TBH. The current API is 'not good' IMHO.

yaustar commented 3 years ago

I guess the could destroy and create a new canvas font object but that would mean reassigning the new font object to all the text elements which is what I think the client wants to avoid doing.