fix reds
[kugel-rb.git] / firmware / export / font.h
blob0fe6c30f2cfe7f94530b13f63672a3188d596222
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
38 * Fonts are specified by number, and used for display
39 * of menu information as well as mp3 filename data.
40 * At system startup, up to MAXFONTS fonts are initialized,
41 * either by being compiled-in, or loaded from disk.
42 * If the font asked for does not exist, then the
43 * system uses the next lower font number. Font 0
44 * must be available at system startup.
45 * Fonts are specified in firmware/font.c.
47 enum {
48 FONT_SYSFIXED, /* system fixed pitch font*/
49 FONT_UI, /* system porportional font*/
50 MAXFONTS
54 * .fnt loadable font file format definition
56 * format len description
57 * ------------------------- ---- ------------------------------
58 * UCHAR version[4] 4 magic number and version bytes
59 * USHORT maxwidth 2 font max width in pixels
60 * USHORT height 2 font height in pixels
61 * USHORT ascent 2 font ascent (baseline) in pixels
62 * USHORT pad 2 unused, pad to 32-bit boundary
63 * ULONG firstchar 4 first character code in font
64 * ULONG defaultchar 4 default character code in font
65 * ULONG size 4 # characters in font
66 * ULONG nbits 4 # bytes imagebits data in file
67 * ULONG noffset 4 # longs offset data in file
68 * ULONG nwidth 4 # bytes width data in file
69 * MWIMAGEBITS bits nbits image bits variable data
70 * [MWIMAGEBITS padded to 16-bit boundary]
71 * USHORT offset noffset*2 offset variable data
72 * UCHAR width nwidth*1 width variable data
75 /* loadable font magic and version #*/
76 #define VERSION "RB12"
78 /* builtin C-based proportional/fixed font structure */
79 /* based on The Microwindows Project http://microwindows.org */
80 struct font {
81 int maxwidth; /* max width in pixels*/
82 unsigned int height; /* height in pixels*/
83 int ascent; /* ascent (baseline) height*/
84 int firstchar; /* first character in bitmap*/
85 int size; /* font size in glyphs*/
86 const unsigned char *bits; /* 8-bit column bitmap data*/
87 const void *offset; /* offsets into bitmap data,
88 uint16_t if bits_size < 0xFFDB else uint32_t*/
89 const unsigned char *width; /* character widths or NULL if fixed*/
90 int defaultchar; /* default char (not glyph index)*/
91 int32_t bits_size; /* # bytes of glyph bits*/
94 /* font routines*/
95 void font_init(void);
96 struct font* font_load(const char *path);
97 struct font* font_get(int font);
98 void font_reset(void);
99 int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
100 int font_get_width(struct font* ft, unsigned short ch);
101 const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
102 void glyph_cache_save(void);
104 #else /* HAVE_LCD_BITMAP */
106 #define font_init()
107 #define font_load(x)
109 #endif
111 #endif