Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: plugin API - font_unload

Re: plugin API - font_unload

From: Jonathan Gordon <jdgordy_at_gmail.com>
Date: Sun, 12 Dec 2010 09:17:44 +1100

On 12 December 2010 07:14, Karl Koehler <koehlerkarl_at_comcast.net> wrote:
> Hi,
>
> 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
>  rb->font_unload(fontId)
>
> 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 ?
>
> Thanks,
>
>  - 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
aaa