Rockbox mail archive
Subject: Re: plugin API - font_unload
Re: plugin API - font_unload
On 12 December 2010 07:14, Karl Koehler <koehlerkarl_at_comcast.net> wrote:
> I'm just getting started with plugin development; and I already seem to have
> some questions regarding the font API.
> Namely, if I load a non-system font with
> struct font* font = (struct font*)malloc(sizeof(struct font));
> int fontId = rb->font_load(font, name);
> then at the end, I feel I should be able to do
> Now font_load doesn't know if the font was malloc'd or just a stack variable
> in plugin_start, thus the system can not free the memory.
> But if I just free the memory, then the slot will remain taken, leading to a
> resource leak.
> And possible crashes if another plugin want to use the same slot when it's
> font-loading fails.
> I see that rockpaint does only one font at a time, loading each to the
> default slot, which seems wasteful in terms of CPU resources - it doesn't
> seem right to load/unload all the time.
> Do we have a way to unload fonts in the plugin-API ? ( I see there is an API
> in firmware/export/font.h , but surely I should not be mucking with this
> directly ?
> - Karl
You are correct. Plugin font loading has been on my todo list since it
was added to the skin system, basically the idea has been to add a
plugin wrapper for skin_font_load() in the plugin lib so fonts could
be easily managed by plugins.
The way to do it would be probably reimplementing skin_font_load() in
the plugin lib so it can check if the requested font is already loaded
and if not load it into a buffer.
Received on 2010-12-11
Page was last modified "Jan 10 2012" The Rockbox Crew