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: fredwbauer: r30826 - in trunk: apps apps/gui firmware firmware/export

Re: fredwbauer: r30826 - in trunk: apps apps/gui firmware firmware/export

From: Jonathan Gordon <jdgordy_at_gmail.com>
Date: Tue, 25 Oct 2011 16:50:25 +1100

Attached is 90% of the work to do this somewhat more nicely.
The remaining work is to check each plugin and make sure they don't
use lcd_setfont() directly (which a quick look shows alot do :( ) the
quick fix for that is just put a wrapper in the plugin api for it like
what has been added for the screen_access api.

On 23 October 2011 16:31, Jonathan Gordon <jdgordy_at_gmail.com> wrote:
> Can this please be reverted? firmware/fonts.c should now know or care
> about the ui font at all, and post buflib fonts it doesnt.
> screen_access.c added a helper to set the font
> (screens[screen].set_font() ) which should be being used by the
> keyboard and lrcviewer. If those are still having issues then that
> helper might need more work. (actually it appears keyboard.c needs to
> use font_get() which has no helper to get
> global_status.font_id[screen].
>
> Ideally a font_get_height() function be added which (to the screen
> api) to get the correct font height seen as that is what most calls to
> font_get() actually care about.
>
> On 23 October 2011 04:13,  <mailer_at_svn.rockbox.org> wrote:
>> Date: 2011-10-22 19:13:33 +0200 (Sat, 22 Oct 2011)
>> New Revision: 30826
>>
>> Log Message:
>> Add functions font_set_ui() and font_get_ui(). The font returned by FONT_UI used to be fixed at zero but since buflib-fonts (r30589) can be different, depending on the order of loads and unloads. Fixes broken behavoir in virtual keyboard (FS#12336), lyrics player (FS#12306), and hopefully, FS#12337
>>
>> Modified:
>>   trunk/apps/filetree.c
>>   trunk/apps/gui/list.c
>>   trunk/apps/settings.c
>>   trunk/firmware/export/font.h
>>   trunk/firmware/font.c
>>
>> Modified: trunk/apps/filetree.c
>> ===================================================================
>> --- trunk/apps/filetree.c       2011-10-22 15:28:09 UTC (rev 30825)
>> +++ trunk/apps/filetree.c       2011-10-22 17:13:33 UTC (rev 30826)
>> @@ -427,7 +427,10 @@
>>     current_font_id = global_status.font_id[screen];
>>     if (current_font_id >= 0)
>>         font_unload(current_font_id);
>> -    global_status.font_id[screen] = font_load(file);
>> +    current_font_id = font_load(file);
>> +    if(screen==SCREEN_MAIN)
>> +        font_set_ui(current_font_id);
>> +    global_status.font_id[screen] = current_font_id;
>>     viewportmanager_theme_changed(THEME_UI_VIEWPORT);
>>  }
>>  #endif
>>
>> Modified: trunk/apps/gui/list.c
>> ===================================================================
>> --- trunk/apps/gui/list.c       2011-10-22 15:28:09 UTC (rev 30825)
>> +++ trunk/apps/gui/list.c       2011-10-22 17:13:33 UTC (rev 30826)
>> @@ -133,6 +133,7 @@
>>  static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen)
>>  {
>>     struct viewport *vp = list->parent[screen];
>> +    vp->line_height = font_get(vp->font)->height;
>>     int lines = skinlist_get_line_count(screen, list);
>>     if (lines < 0)
>>     {
>>
>> Modified: trunk/apps/settings.c
>> ===================================================================
>> --- trunk/apps/settings.c       2011-10-22 15:28:09 UTC (rev 30825)
>> +++ trunk/apps/settings.c       2011-10-22 17:13:33 UTC (rev 30826)
>> @@ -886,6 +886,7 @@
>>                 if (global_status.font_id[SCREEN_MAIN] >= 0)
>>                     font_unload(global_status.font_id[SCREEN_MAIN]);
>>                 rc = font_load(buf);
>> +                font_set_ui(rc);
>>                 CHART2("<font_load ", global_settings.font_file);
>>                 global_status.font_id[SCREEN_MAIN] = rc;
>>                 lcd_setfont(rc);
>>
>> Modified: trunk/firmware/export/font.h
>> ===================================================================
>> --- trunk/firmware/export/font.h        2011-10-22 15:28:09 UTC (rev 30825)
>> +++ trunk/firmware/export/font.h        2011-10-22 17:13:33 UTC (rev 30826)
>> @@ -55,7 +55,7 @@
>>
>>  /* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */
>>  #define MAXFONTS (FONT_FIRSTUSERFONT + MAXUSERFONTS)
>> -#define FONT_UI MAXFONTS
>> +#define FONT_UI MAXUSERFONTS
>>
>>  /*
>>  * .fnt loadable font file format definition
>> @@ -124,6 +124,9 @@
>>  void font_unload(int font_id);
>>  void font_unload_all(void);
>>  void font_lock(int font_id, bool lock);
>> +/* set the default UI font */
>> +void font_set_ui(int font_id);
>> +int  font_get_ui(void);
>>
>>  struct font* font_get(int font);
>>
>>
>> Modified: trunk/firmware/font.c
>> ===================================================================
>> --- trunk/firmware/font.c       2011-10-22 15:28:09 UTC (rev 30825)
>> +++ trunk/firmware/font.c       2011-10-22 17:13:33 UTC (rev 30826)
>> @@ -88,6 +88,7 @@
>>  };
>>  static int buflib_allocations[MAXFONTS];
>>
>> +static int font_ui = -1;
>>  static int cache_fd;
>>  static struct font* cache_pf;
>>
>> @@ -559,7 +560,7 @@
>>
>>     lock_font_handle(handle, false);
>>     buflib_allocations[font_id] = handle;
>> -    //printf("%s -> [%d] -> %d\n", path, font_id, *handle);
>> +    //printf("%s -> [%d] -> %d\n", path, font_id, handle);
>>     return font_id; /* success!*/
>>  }
>>  int font_load(const char *path)
>> @@ -616,30 +617,54 @@
>>
>>  /*
>>  * Return a pointer to an incore font structure.
>> - * If the requested font isn't loaded/compiled-in,
>> - * decrement the font number and try again.
>> + * Return the requested font, font_ui, or sysfont
>>  */
>> -struct font* font_get(int font)
>> +struct font* font_get(int font_id)
>>  {
>> -    struct font* pf;
>> -    if (font == FONT_UI)
>> -        font = MAXFONTS-1;
>> -    if (font <= FONT_SYSFIXED)
>> +    struct buflib_alloc_data *alloc;
>> +    struct font *pf;
>> +    int handle, id=-1;
>> +
>> +    if( font_id == FONT_UI )
>> +        id = font_ui;
>> +
>> +    if( font_id == FONT_SYSFIXED )
>>         return &sysfont;
>> +
>> +    if( id == -1 )
>> +        id = font_id;
>> +
>> +    handle = buflib_allocations[id];
>> +    if( handle > 0 )
>> +    {
>> +        alloc =  core_get_data(buflib_allocations[id]);
>> +        pf=&alloc->font;
>> +        if( pf && pf->height )
>> +            return pf;
>> +    }
>> +    handle = buflib_allocations[font_ui];
>> +    if( handle > 0 )
>> +    {
>> +        alloc = core_get_data(buflib_allocations[font_ui]);
>> +        pf=&alloc->font;
>> +        if( pf && pf->height )
>> +            return pf;
>> +    }
>>
>> -    while (1) {
>> -        if (buflib_allocations[font] > 0)
>> -        {
>> -            struct buflib_alloc_data *alloc = core_get_data(buflib_allocations[font]);
>> -            pf = &alloc->font;
>> -            if (pf && pf->height)
>> -                return pf;
>> -        }
>> -        if (--font < 0)
>> -            return &sysfont;
>> -    }
>> +    return &sysfont;
>>  }
>>
>> +void font_set_ui( int font_id )
>> +{
>> +    font_ui = font_id;
>> +    return;
>> +}
>> +
>> +int font_get_ui()
>> +{
>> +    return font_ui;
>> +}
>> +
>>  static int pf_to_handle(struct font* pf)
>>  {
>>     int i;
>> @@ -980,6 +1005,18 @@
>>     return &sysfont;
>>  }
>>
>> +void font_set_ui(int font_id)
>> +{
>> +    (void)font_id;
>> +    return;
>> +}
>> +
>> +int font_get_ui()
>> +{
>> +    return FONT_SYSFIXED;
>> +}
>> +
>> +
>>  /*
>>  * Returns width of character
>>  */
>>
>> _______________________________________________
>> rockbox-cvs mailing list
>> rockbox-cvs_at_cool.haxx.se
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs
>>
>

Received on 2011-10-25

Page was last modified "Jan 10 2012" The Rockbox Crew
aaa