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)
32 /* max static loadable font buffer size */
36 #define MAX_FONT_SIZE 60000
38 #define MAX_FONT_SIZE 10000
41 #define MAX_FONT_SIZE 4000
45 #ifndef FONT_HEADER_SIZE
46 #define FONT_HEADER_SIZE 36
49 #define GLYPH_CACHE_FILE "/.rockbox/.glyphcache"
52 * Fonts are specified by number, and used for display
53 * of menu information as well as mp3 filename data.
54 * At system startup, up to MAXFONTS fonts are initialized,
55 * either by being compiled-in, or loaded from disk.
56 * If the font asked for does not exist, then the
57 * system uses the next lower font number. Font 0
58 * must be available at system startup.
59 * Fonts are specified in firmware/font.c.
62 FONT_SYSFIXED
, /* system fixed pitch font*/
63 FONT_UI
, /* system porportional font*/
68 * .fnt loadable font file format definition
70 * format len description
71 * ------------------------- ---- ------------------------------
72 * UCHAR version[4] 4 magic number and version bytes
73 * USHORT maxwidth 2 font max width in pixels
74 * USHORT height 2 font height in pixels
75 * USHORT ascent 2 font ascent (baseline) in pixels
76 * USHORT pad 2 unused, pad to 32-bit boundary
77 * ULONG firstchar 4 first character code in font
78 * ULONG defaultchar 4 default character code in font
79 * ULONG size 4 # characters in font
80 * ULONG nbits 4 # bytes imagebits data in file
81 * ULONG noffset 4 # longs offset data in file
82 * ULONG nwidth 4 # bytes width data in file
83 * MWIMAGEBITS bits nbits image bits variable data
84 * [MWIMAGEBITS padded to 16-bit boundary]
85 * USHORT offset noffset*2 offset variable data
86 * UCHAR width nwidth*1 width variable data
89 /* loadable font magic and version #*/
90 #define VERSION "RB12"
92 /* builtin C-based proportional/fixed font structure */
93 /* based on The Microwindows Project http://microwindows.org */
95 int maxwidth
; /* max width in pixels*/
96 unsigned int height
; /* height in pixels*/
97 int ascent
; /* ascent (baseline) height*/
98 int firstchar
; /* first character in bitmap*/
99 int size
; /* font size in glyphs*/
100 const unsigned char *bits
; /* 8-bit column bitmap data*/
101 const unsigned short *offset
; /* offsets into bitmap data*/
102 const unsigned char *width
; /* character widths or NULL if fixed*/
103 int defaultchar
; /* default char (not glyph index)*/
104 int32_t bits_size
; /* # bytes of glyph bits*/
108 void font_init(void);
109 struct font
* font_load(const char *path
);
110 struct font
* font_get(int font
);
111 void font_reset(void);
112 int font_getstringsize(const unsigned char *str
, int *w
, int *h
, int fontnumber
);
113 int font_get_width(struct font
* ft
, unsigned short ch
);
114 const unsigned char * font_get_bits(struct font
* ft
, unsigned short ch
);
115 void glyph_cache_save(void);
117 #else /* HAVE_LCD_BITMAP */