diff options
author | Fred Bauer <fred.w.bauer@gmail.com> | 2011-10-22 17:13:33 +0000 |
---|---|---|
committer | Fred Bauer <fred.w.bauer@gmail.com> | 2011-10-22 17:13:33 +0000 |
commit | e299eb3ea36cba48875cf35bb1dcc93eaba0d279 (patch) | |
tree | a2d9e853522207fae414d82c9f5e6dba81252ea4 /firmware/font.c | |
parent | 4d2ab32339fb8e7c02841e52d35498081503d188 (diff) | |
download | rockbox-e299eb3ea36cba48875cf35bb1dcc93eaba0d279.tar.gz rockbox-e299eb3ea36cba48875cf35bb1dcc93eaba0d279.zip |
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
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30826 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/font.c')
-rw-r--r-- | firmware/font.c | 75 |
1 files changed, 56 insertions, 19 deletions
diff --git a/firmware/font.c b/firmware/font.c index f1cddb0f3c..eb15bb7420 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -88,6 +88,7 @@ struct buflib_alloc_data { | |||
88 | }; | 88 | }; |
89 | static int buflib_allocations[MAXFONTS]; | 89 | static int buflib_allocations[MAXFONTS]; |
90 | 90 | ||
91 | static int font_ui = -1; | ||
91 | static int cache_fd; | 92 | static int cache_fd; |
92 | static struct font* cache_pf; | 93 | static struct font* cache_pf; |
93 | 94 | ||
@@ -559,7 +560,7 @@ int font_load_ex(const char *path, size_t buffer_size) | |||
559 | 560 | ||
560 | lock_font_handle(handle, false); | 561 | lock_font_handle(handle, false); |
561 | buflib_allocations[font_id] = handle; | 562 | buflib_allocations[font_id] = handle; |
562 | //printf("%s -> [%d] -> %d\n", path, font_id, *handle); | 563 | //printf("%s -> [%d] -> %d\n", path, font_id, handle); |
563 | return font_id; /* success!*/ | 564 | return font_id; /* success!*/ |
564 | } | 565 | } |
565 | int font_load(const char *path) | 566 | int font_load(const char *path) |
@@ -616,28 +617,52 @@ void font_unload_all(void) | |||
616 | 617 | ||
617 | /* | 618 | /* |
618 | * Return a pointer to an incore font structure. | 619 | * Return a pointer to an incore font structure. |
619 | * If the requested font isn't loaded/compiled-in, | 620 | * Return the requested font, font_ui, or sysfont |
620 | * decrement the font number and try again. | ||
621 | */ | 621 | */ |
622 | struct font* font_get(int font) | 622 | struct font* font_get(int font_id) |
623 | { | 623 | { |
624 | struct font* pf; | 624 | struct buflib_alloc_data *alloc; |
625 | if (font == FONT_UI) | 625 | struct font *pf; |
626 | font = MAXFONTS-1; | 626 | int handle, id=-1; |
627 | if (font <= FONT_SYSFIXED) | ||
628 | return &sysfont; | ||
629 | 627 | ||
630 | while (1) { | 628 | if( font_id == FONT_UI ) |
631 | if (buflib_allocations[font] > 0) | 629 | id = font_ui; |
632 | { | 630 | |
633 | struct buflib_alloc_data *alloc = core_get_data(buflib_allocations[font]); | 631 | if( font_id == FONT_SYSFIXED ) |
634 | pf = &alloc->font; | 632 | return &sysfont; |
635 | if (pf && pf->height) | 633 | |
636 | return pf; | 634 | if( id == -1 ) |
637 | } | 635 | id = font_id; |
638 | if (--font < 0) | 636 | |
639 | return &sysfont; | 637 | handle = buflib_allocations[id]; |
638 | if( handle > 0 ) | ||
639 | { | ||
640 | alloc = core_get_data(buflib_allocations[id]); | ||
641 | pf=&alloc->font; | ||
642 | if( pf && pf->height ) | ||
643 | return pf; | ||
644 | } | ||
645 | handle = buflib_allocations[font_ui]; | ||
646 | if( handle > 0 ) | ||
647 | { | ||
648 | alloc = core_get_data(buflib_allocations[font_ui]); | ||
649 | pf=&alloc->font; | ||
650 | if( pf && pf->height ) | ||
651 | return pf; | ||
640 | } | 652 | } |
653 | |||
654 | return &sysfont; | ||
655 | } | ||
656 | |||
657 | void font_set_ui( int font_id ) | ||
658 | { | ||
659 | font_ui = font_id; | ||
660 | return; | ||
661 | } | ||
662 | |||
663 | int font_get_ui() | ||
664 | { | ||
665 | return font_ui; | ||
641 | } | 666 | } |
642 | 667 | ||
643 | static int pf_to_handle(struct font* pf) | 668 | static int pf_to_handle(struct font* pf) |
@@ -980,6 +1005,18 @@ struct font* font_get(int font) | |||
980 | return &sysfont; | 1005 | return &sysfont; |
981 | } | 1006 | } |
982 | 1007 | ||
1008 | void font_set_ui(int font_id) | ||
1009 | { | ||
1010 | (void)font_id; | ||
1011 | return; | ||
1012 | } | ||
1013 | |||
1014 | int font_get_ui() | ||
1015 | { | ||
1016 | return FONT_SYSFIXED; | ||
1017 | } | ||
1018 | |||
1019 | |||
983 | /* | 1020 | /* |
984 | * Returns width of character | 1021 | * Returns width of character |
985 | */ | 1022 | */ |