summaryrefslogtreecommitdiff
path: root/firmware/font.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-11-08 10:09:33 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-11-08 10:09:33 +0000
commitf19f3efb078b2947638f6f7a7f209de44daf78b3 (patch)
tree46ddfc7234b2de6e848d5bcd7630821d91a84f37 /firmware/font.c
parent452a3ce2742949e184d6bc9c9b1f7985dae3e874 (diff)
downloadrockbox-f19f3efb078b2947638f6f7a7f209de44daf78b3.tar.gz
rockbox-f19f3efb078b2947638f6f7a7f209de44daf78b3.zip
Redo r30826 (and hopefully not reintroduce font issues) which cleans up the font API. FONT_UI is deprecated, use screens[screen].getuifont() instead (and .setuifont() to set it after a font has been loaded)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30932 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/font.c')
-rw-r--r--firmware/font.c75
1 files changed, 19 insertions, 56 deletions
diff --git a/firmware/font.c b/firmware/font.c
index 8e576016bd..ff5bc4b008 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -88,7 +88,6 @@ struct buflib_alloc_data {
88}; 88};
89static int buflib_allocations[MAXFONTS]; 89static int buflib_allocations[MAXFONTS];
90 90
91static int font_ui = -1;
92static int cache_fd; 91static int cache_fd;
93static struct font* cache_pf; 92static struct font* cache_pf;
94 93
@@ -560,7 +559,7 @@ int font_load_ex(const char *path, size_t buffer_size)
560 559
561 lock_font_handle(handle, false); 560 lock_font_handle(handle, false);
562 buflib_allocations[font_id] = handle; 561 buflib_allocations[font_id] = handle;
563 //printf("%s -> [%d] -> %d\n", path, font_id, handle); 562 //printf("%s -> [%d] -> %d\n", path, font_id, *handle);
564 return font_id; /* success!*/ 563 return font_id; /* success!*/
565} 564}
566int font_load(const char *path) 565int font_load(const char *path)
@@ -617,52 +616,28 @@ void font_unload_all(void)
617 616
618/* 617/*
619 * Return a pointer to an incore font structure. 618 * Return a pointer to an incore font structure.
620 * Return the requested font, font_ui, or sysfont 619 * If the requested font isn't loaded/compiled-in,
620 * decrement the font number and try again.
621 */ 621 */
622struct font* font_get(int font_id) 622struct font* font_get(int font)
623{ 623{
624 struct buflib_alloc_data *alloc; 624 struct font* pf;
625 struct font *pf; 625 if (font == FONT_UI)
626 int handle, id=-1; 626 font = MAXFONTS-1;
627 627 if (font <= FONT_SYSFIXED)
628 if( font_id == FONT_UI )
629 id = font_ui;
630
631 if( font_id == FONT_SYSFIXED )
632 return &sysfont; 628 return &sysfont;
633
634 if( id == -1 )
635 id = font_id;
636
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;
652 }
653
654 return &sysfont;
655}
656
657void font_set_ui( int font_id )
658{
659 font_ui = font_id;
660 return;
661}
662 629
663int font_get_ui() 630 while (1) {
664{ 631 if (buflib_allocations[font] > 0)
665 return font_ui; 632 {
633 struct buflib_alloc_data *alloc = core_get_data(buflib_allocations[font]);
634 pf = &alloc->font;
635 if (pf && pf->height)
636 return pf;
637 }
638 if (--font < 0)
639 return &sysfont;
640 }
666} 641}
667 642
668static int pf_to_handle(struct font* pf) 643static int pf_to_handle(struct font* pf)
@@ -1004,18 +979,6 @@ struct font* font_get(int font)
1004 return &sysfont; 979 return &sysfont;
1005} 980}
1006 981
1007void font_set_ui(int font_id)
1008{
1009 (void)font_id;
1010 return;
1011}
1012
1013int font_get_ui()
1014{
1015 return FONT_SYSFIXED;
1016}
1017
1018
1019/* 982/*
1020 * Returns width of character 983 * Returns width of character
1021 */ 984 */