Colour targets: Revert an optimisation from almost 18 months ago that actually turned...
[Rockbox.git] / firmware / export / font.h
blobe3455f9c7014b367f119546f3772cf267831bbb5
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #ifndef _FONT_H
22 #define _FONT_H
24 #include "inttypes.h"
27 * Incore font and image definitions
29 #include "config.h"
31 #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
32 #ifndef __PCTOOL__
33 #include "sysfont.h"
34 #endif
36 /* max static loadable font buffer size */
37 #ifndef MAX_FONT_SIZE
38 #if LCD_HEIGHT > 64
39 #if MEM > 2
40 #define MAX_FONT_SIZE 60000
41 #else
42 #define MAX_FONT_SIZE 10000
43 #endif
44 #else
45 #define MAX_FONT_SIZE 4000
46 #endif
47 #endif
49 #ifndef FONT_HEADER_SIZE
50 #define FONT_HEADER_SIZE 36
51 #endif
53 #define GLYPH_CACHE_FILE "/.rockbox/.glyphcache"
56 * Fonts are specified by number, and used for display
57 * of menu information as well as mp3 filename data.
58 * At system startup, up to MAXFONTS fonts are initialized,
59 * either by being compiled-in, or loaded from disk.
60 * If the font asked for does not exist, then the
61 * system uses the next lower font number. Font 0
62 * must be available at system startup.
63 * Fonts are specified in firmware/font.c.
65 enum {
66 FONT_SYSFIXED, /* system fixed pitch font*/
67 FONT_UI, /* system porportional font*/
68 MAXFONTS
72 * .fnt loadable font file format definition
74 * format len description
75 * ------------------------- ---- ------------------------------
76 * UCHAR version[4] 4 magic number and version bytes
77 * USHORT maxwidth 2 font max width in pixels
78 * USHORT height 2 font height in pixels
79 * USHORT ascent 2 font ascent (baseline) in pixels
80 * USHORT pad 2 unused, pad to 32-bit boundary
81 * ULONG firstchar 4 first character code in font
82 * ULONG defaultchar 4 default character code in font
83 * ULONG size 4 # characters in font
84 * ULONG nbits 4 # bytes imagebits data in file
85 * ULONG noffset 4 # longs offset data in file
86 * ULONG nwidth 4 # bytes width data in file
87 * MWIMAGEBITS bits nbits image bits variable data
88 * [MWIMAGEBITS padded to 16-bit boundary]
89 * USHORT offset noffset*2 offset variable data
90 * UCHAR width nwidth*1 width variable data
93 /* loadable font magic and version #*/
94 #define VERSION "RB12"
96 /* builtin C-based proportional/fixed font structure */
97 /* based on The Microwindows Project http://microwindows.org */
98 struct font {
99 int maxwidth; /* max width in pixels*/
100 unsigned int height; /* height in pixels*/
101 int ascent; /* ascent (baseline) height*/
102 int firstchar; /* first character in bitmap*/
103 int size; /* font size in glyphs*/
104 const unsigned char *bits; /* 8-bit column bitmap data*/
105 const unsigned short *offset; /* offsets into bitmap data*/
106 const unsigned char *width; /* character widths or NULL if fixed*/
107 int defaultchar; /* default char (not glyph index)*/
108 int32_t bits_size; /* # bytes of glyph bits*/
111 /* font routines*/
112 void font_init(void);
113 struct font* font_load(const char *path);
114 struct font* font_get(int font);
115 void font_reset(void);
116 int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
117 int font_get_width(struct font* ft, unsigned short ch);
118 const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
119 void glyph_cache_save(void);
121 #else /* HAVE_LCD_BITMAP */
123 #define font_init()
124 #define font_load(x)
126 #endif
128 #endif