1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 * Incore font and image definitions
29 #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
34 /* max static loadable font buffer size */
38 #define MAX_FONT_SIZE 60000
40 #define MAX_FONT_SIZE 10000
43 #define MAX_FONT_SIZE 4000
47 #ifndef FONT_HEADER_SIZE
48 #define FONT_HEADER_SIZE 36
51 #define GLYPH_CACHE_FILE "/.rockbox/.glyphcache"
54 * Fonts are specified by number, and used for display
55 * of menu information as well as mp3 filename data.
56 * At system startup, up to MAXFONTS fonts are initialized,
57 * either by being compiled-in, or loaded from disk.
58 * If the font asked for does not exist, then the
59 * system uses the next lower font number. Font 0
60 * must be available at system startup.
61 * Fonts are specified in firmware/font.c.
64 FONT_SYSFIXED
, /* system fixed pitch font*/
65 FONT_UI
, /* system porportional font*/
70 * .fnt loadable font file format definition
72 * format len description
73 * ------------------------- ---- ------------------------------
74 * UCHAR version[4] 4 magic number and version bytes
75 * USHORT maxwidth 2 font max width in pixels
76 * USHORT height 2 font height in pixels
77 * USHORT ascent 2 font ascent (baseline) in pixels
78 * USHORT pad 2 unused, pad to 32-bit boundary
79 * ULONG firstchar 4 first character code in font
80 * ULONG defaultchar 4 default character code in font
81 * ULONG size 4 # characters in font
82 * ULONG nbits 4 # bytes imagebits data in file
83 * ULONG noffset 4 # longs offset data in file
84 * ULONG nwidth 4 # bytes width data in file
85 * MWIMAGEBITS bits nbits image bits variable data
86 * [MWIMAGEBITS padded to 16-bit boundary]
87 * USHORT offset noffset*2 offset variable data
88 * UCHAR width nwidth*1 width variable data
91 /* loadable font magic and version #*/
92 #define VERSION "RB12"
94 /* builtin C-based proportional/fixed font structure */
95 /* based on The Microwindows Project http://microwindows.org */
97 int maxwidth
; /* max width in pixels*/
98 unsigned int height
; /* height in pixels*/
99 int ascent
; /* ascent (baseline) height*/
100 int firstchar
; /* first character in bitmap*/
101 int size
; /* font size in glyphs*/
102 const unsigned char *bits
; /* 8-bit column bitmap data*/
103 const unsigned short *offset
; /* offsets into bitmap data*/
104 const unsigned char *width
; /* character widths or NULL if fixed*/
105 int defaultchar
; /* default char (not glyph index)*/
106 int32_t bits_size
; /* # bytes of glyph bits*/
110 void font_init(void);
111 struct font
* font_load(const char *path
);
112 struct font
* font_get(int font
);
113 void font_reset(void);
114 int font_getstringsize(const unsigned char *str
, int *w
, int *h
, int fontnumber
);
115 int font_get_width(struct font
* ft
, unsigned short ch
);
116 const unsigned char * font_get_bits(struct font
* ft
, unsigned short ch
);
117 void glyph_cache_save(void);
119 #else /* HAVE_LCD_BITMAP */