diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-09-12 13:33:59 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-09-12 13:33:59 +0000 |
commit | 93b231c69366563ba441dc4907bfb036fe3b4c55 (patch) | |
tree | 0783ad028211f59e63925a354e4260a7209ffa24 /firmware/font.h | |
parent | 5ed78ea80cdaa0ede4df89568f0781fa477a5738 (diff) | |
download | rockbox-93b231c69366563ba441dc4907bfb036fe3b4c55.tar.gz rockbox-93b231c69366563ba441dc4907bfb036fe3b4c55.zip |
Greg Haerr's new loadable font. No more #ifdef font-style, removed old
propfont and loadable font code. New font file format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2269 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/font.h')
-rw-r--r-- | firmware/font.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/firmware/font.h b/firmware/font.h new file mode 100644 index 0000000000..13d60e560b --- /dev/null +++ b/firmware/font.h | |||
@@ -0,0 +1,126 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (c) 2002 by Greg Haerr <greg@censoft.com> | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | /* | ||
20 | * Incore font and image definitions | ||
21 | */ | ||
22 | #include "config.h" | ||
23 | |||
24 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) | ||
25 | |||
26 | /* max static loadable fonts buffer*/ | ||
27 | #ifndef MAX_FONT_SIZE | ||
28 | #define MAX_FONT_SIZE 9000 /* max total fontsize allocation*/ | ||
29 | #endif | ||
30 | |||
31 | /* | ||
32 | * Fonts are specified by number, and used for display | ||
33 | * of menu information as well as mp3 filename data. | ||
34 | * At system startup, up to MAXFONTS fonts are initialized, | ||
35 | * either by being compiled-in, or loaded from disk. | ||
36 | * If the font asked for does not exist, then the | ||
37 | * system uses the next lower font number. Font 0 | ||
38 | * must be available at system startup. | ||
39 | * Fonts are specified in firmware/font.c. | ||
40 | */ | ||
41 | #define FONT_SYSFIXED 0 /* system fixed pitch font*/ | ||
42 | #define FONT_UI 1 /* system porportional font*/ | ||
43 | #define FONT_MP3 2 /* font used for mp3 info*/ | ||
44 | #define MAXFONTS 3 /* max # fonts*/ | ||
45 | |||
46 | /* | ||
47 | * .fnt (.rbf) loadable font file format definition | ||
48 | * | ||
49 | * format len description | ||
50 | * ------------------------- ---- ------------------------------ | ||
51 | * UCHAR version[4] 4 magic number and version bytes | ||
52 | * UCHAR name[64] 64 font name, space padded | ||
53 | * UCHAR copyright[256] 256 copyright info, space padded | ||
54 | * USHORT maxwidth 2 font max width in pixels | ||
55 | * USHORT height 2 font height in pixels | ||
56 | * USHORT ascent 2 font ascent (baseline) in pixels | ||
57 | * ULONG firstchar 4 first character code in font | ||
58 | * ULONG defaultchar 4 default character code in font | ||
59 | * ULONG size 4 # characters in font | ||
60 | * ULONG nbits 4 # words imagebits data in file | ||
61 | * ULONG noffset 4 # longs offset data in file | ||
62 | * ULONG nwidth 4 # bytes width data in file | ||
63 | * MWIMAGEBITS bits nbits*2 image bits variable data | ||
64 | * ULONG offset noffset*4 offset variable data | ||
65 | * UCHAR width nwidth*1 width variable data | ||
66 | */ | ||
67 | |||
68 | /* loadable font magic and version #*/ | ||
69 | #define VERSION "RB10" | ||
70 | |||
71 | /* MWIMAGEBITS helper macros*/ | ||
72 | #define MWIMAGE_WORDS(x) (((x)+15)/16) /* image size in words*/ | ||
73 | #define MWIMAGE_BYTES(x) (((x)+7)/8) /* image size in bytes*/ | ||
74 | #define MWIMAGE_BITSPERIMAGE (sizeof(MWIMAGEBITS) * 8) | ||
75 | #define MWIMAGE_BITVALUE(n) ((MWIMAGEBITS) (((MWIMAGEBITS) 1) << (n))) | ||
76 | #define MWIMAGE_FIRSTBIT (MWIMAGE_BITVALUE(MWIMAGE_BITSPERIMAGE - 1)) | ||
77 | #define MWIMAGE_TESTBIT(m) ((m) & MWIMAGE_FIRSTBIT) | ||
78 | #define MWIMAGE_SHIFTBIT(m) ((MWIMAGEBITS) ((m) << 1)) | ||
79 | |||
80 | typedef unsigned short MWIMAGEBITS; /* bitmap image unit size*/ | ||
81 | |||
82 | /* builtin C-based proportional/fixed font structure */ | ||
83 | /* based on The Microwindows Project http://microwindows.org */ | ||
84 | typedef struct { | ||
85 | char * name; /* font name*/ | ||
86 | int maxwidth; /* max width in pixels*/ | ||
87 | unsigned int height; /* height in pixels*/ | ||
88 | int ascent; /* ascent (baseline) height*/ | ||
89 | int firstchar; /* first character in bitmap*/ | ||
90 | int size; /* font size in glyphs*/ | ||
91 | MWIMAGEBITS *bits; /* 16-bit right-padded bitmap data*/ | ||
92 | unsigned long *offset; /* offsets into bitmap data*/ | ||
93 | unsigned char *width; /* character widths or NULL if fixed*/ | ||
94 | int defaultchar; /* default char (not glyph index)*/ | ||
95 | long bits_size; /* # words of MWIMAGEBITS bits*/ | ||
96 | #if 0 | ||
97 | char * facename; /* facename of font*/ | ||
98 | char * copyright; /* copyright info for loadable fonts*/ | ||
99 | #endif | ||
100 | } MWCFONT, *PMWCFONT; | ||
101 | |||
102 | /* structure for rockbox startup font selection*/ | ||
103 | struct corefont { | ||
104 | PMWCFONT pf; /* compiled-in or loaded font*/ | ||
105 | char *diskname; /* diskname if not compiled-in*/ | ||
106 | }; | ||
107 | |||
108 | extern struct corefont sysfonts[MAXFONTS]; | ||
109 | |||
110 | /* font routines*/ | ||
111 | PMWCFONT getfont(int font); | ||
112 | PMWCFONT rbf_load_font(char *path, PMWCFONT pf); | ||
113 | |||
114 | void font_init(void); | ||
115 | |||
116 | #else /* HAVE_LCD_BITMAP */ | ||
117 | |||
118 | #define font_init() | ||
119 | |||
120 | #endif | ||
121 | |||
122 | /* ----------------------------------------------------------------- | ||
123 | * local variables: | ||
124 | * eval: (load-file "rockbox-mode.el") | ||
125 | * end: | ||
126 | */ | ||