Currently, LunaSVG provides APIs to add font faces to the global font cache:
• lunasvg_add_font_face_from_file()
• lunasvg_add_font_face_from_data()
However, there is no corresponding API to remove a font face from the cache. This makes it impossible to properly manage font lifecycle in applications that need to dynamically load and unload fonts.
In our application (Multi Theft Auto), we allow users to register custom fonts for SVG rendering at runtime via 'resources'. When a resource (similar to a plugin/module) is unloaded, we need to clean up all associated fonts. Without a removal API:
- Memory leak: The font data passed to
lunasvg_add_font_face_from_data() with a destroy_func callback is never freed because the internal plutovg_font_face_cache holds a reference indefinitely.
- Font name conflicts: The cache uses the font family name as a lookup key. When lunasvg_add_font_face_from_data() is called with a family name that already exists in the cache, the behavior is undefined from the API consumer's perspective
- No cleanup path: Applications have no way to release font resources without terminating.
The proposal is to add a public API such as lunasvg_remove_font_face() to address this.
Using LunaSVG version: 3.5.0 (PlutoVG bundled)
Currently, LunaSVG provides APIs to add font faces to the global font cache:
•
lunasvg_add_font_face_from_file()•
lunasvg_add_font_face_from_data()However, there is no corresponding API to remove a font face from the cache. This makes it impossible to properly manage font lifecycle in applications that need to dynamically load and unload fonts.
In our application (Multi Theft Auto), we allow users to register custom fonts for SVG rendering at runtime via 'resources'. When a resource (similar to a plugin/module) is unloaded, we need to clean up all associated fonts. Without a removal API:
lunasvg_add_font_face_from_data()with a destroy_func callback is never freed because the internalplutovg_font_face_cacheholds a reference indefinitely.The proposal is to add a public API such as
lunasvg_remove_font_face()to address this.Using LunaSVG version: 3.5.0 (PlutoVG bundled)