summaryrefslogtreecommitdiff
path: root/firmware/font.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/font.h')
-rw-r--r--firmware/font.h53
1 files changed, 21 insertions, 32 deletions
diff --git a/firmware/font.h b/firmware/font.h
index 645848ee18..44b975bb78 100644
--- a/firmware/font.h
+++ b/firmware/font.h
@@ -38,13 +38,14 @@
38 * must be available at system startup. 38 * must be available at system startup.
39 * Fonts are specified in firmware/font.c. 39 * Fonts are specified in firmware/font.c.
40 */ 40 */
41#define FONT_SYSFIXED 0 /* system fixed pitch font*/ 41enum {
42#define FONT_UI 1 /* system porportional font*/ 42 FONT_SYSFIXED, /* system fixed pitch font*/
43#define FONT_MP3 2 /* font used for mp3 info*/ 43 FONT_UI, /* system porportional font*/
44#define MAXFONTS 3 /* max # fonts*/ 44 MAXFONTS
45};
45 46
46/* 47/*
47 * .fnt (.rbf) loadable font file format definition 48 * .fnt loadable font file format definition
48 * 49 *
49 * format len description 50 * format len description
50 * ------------------------- ---- ------------------------------ 51 * ------------------------- ---- ------------------------------
@@ -70,54 +71,42 @@
70/* loadable font magic and version #*/ 71/* loadable font magic and version #*/
71#define VERSION "RB11" 72#define VERSION "RB11"
72 73
73/* MWIMAGEBITS helper macros*/ 74typedef unsigned short bitmap_t; /* bitmap image unit size*/
74#define MWIMAGE_WORDS(x) (((x)+15)/16) /* image size in words*/
75#define MWIMAGE_BYTES(x) (MWIMAGE_WORDS(x)*sizeof(MWIMAGEBITS))
76#define MWIMAGE_BITSPERIMAGE (sizeof(MWIMAGEBITS) * 8)
77#define MWIMAGE_BITVALUE(n) ((MWIMAGEBITS) (((MWIMAGEBITS) 1) << (n)))
78#define MWIMAGE_FIRSTBIT (MWIMAGE_BITVALUE(MWIMAGE_BITSPERIMAGE - 1))
79#define MWIMAGE_TESTBIT(m) ((m) & MWIMAGE_FIRSTBIT)
80#define MWIMAGE_SHIFTBIT(m) ((MWIMAGEBITS) ((m) << 1))
81 75
82typedef unsigned short MWIMAGEBITS; /* bitmap image unit size*/ 76/* bitmap_t helper macros*/
77#define BITMAP_WORDS(x) (((x)+15)/16) /* image size in words*/
78#define BITMAP_BYTES(x) (BITMAP_WORDS(x)*sizeof(bitmap_t))
79#define BITMAP_BITSPERIMAGE (sizeof(bitmap_t) * 8)
80#define BITMAP_BITVALUE(n) ((bitmap_t) (((bitmap_t) 1) << (n)))
81#define BITMAP_FIRSTBIT (BITMAP_BITVALUE(BITMAP_BITSPERIMAGE - 1))
82#define BITMAP_TESTBIT(m) ((m) & BITMAP_FIRSTBIT)
83#define BITMAP_SHIFTBIT(m) ((bitmap_t) ((m) << 1))
83 84
84/* builtin C-based proportional/fixed font structure */ 85/* builtin C-based proportional/fixed font structure */
85/* based on The Microwindows Project http://microwindows.org */ 86/* based on The Microwindows Project http://microwindows.org */
86typedef struct { 87struct font {
87 char * name; /* font name*/ 88 char * name; /* font name*/
88 int maxwidth; /* max width in pixels*/ 89 int maxwidth; /* max width in pixels*/
89 unsigned int height; /* height in pixels*/ 90 unsigned int height; /* height in pixels*/
90 int ascent; /* ascent (baseline) height*/ 91 int ascent; /* ascent (baseline) height*/
91 int firstchar; /* first character in bitmap*/ 92 int firstchar; /* first character in bitmap*/
92 int size; /* font size in glyphs*/ 93 int size; /* font size in glyphs*/
93 MWIMAGEBITS *bits; /* 16-bit right-padded bitmap data*/ 94 bitmap_t *bits; /* 16-bit right-padded bitmap data*/
94 unsigned long *offset; /* offsets into bitmap data*/ 95 unsigned long *offset; /* offsets into bitmap data*/
95 unsigned char *width; /* character widths or NULL if fixed*/ 96 unsigned char *width; /* character widths or NULL if fixed*/
96 int defaultchar; /* default char (not glyph index)*/ 97 int defaultchar; /* default char (not glyph index)*/
97 long bits_size; /* # words of MWIMAGEBITS bits*/ 98 long bits_size; /* # words of bitmap_t bits*/
98#if 0
99 char * facename; /* facename of font*/
100 char * copyright; /* copyright info for loadable fonts*/
101#endif
102} MWCFONT, *PMWCFONT;
103
104/* structure for rockbox startup font selection*/
105struct corefont {
106 PMWCFONT pf; /* compiled-in or loaded font*/
107 char *diskname; /* diskname if not compiled-in*/
108}; 99};
109 100
110extern struct corefont sysfonts[MAXFONTS];
111
112/* font routines*/ 101/* font routines*/
113PMWCFONT getfont(int font);
114PMWCFONT rbf_load_font(char *path, PMWCFONT pf);
115
116void font_init(void); 102void font_init(void);
103struct font* font_load(char *path);
104struct font* font_get(int font);
117 105
118#else /* HAVE_LCD_BITMAP */ 106#else /* HAVE_LCD_BITMAP */
119 107
120#define font_init() 108#define font_init()
109#define font_load(x)
121 110
122#endif 111#endif
123 112