Add Johannes Linke to the header in deutsch.lang too.
[kugel-rb.git] / firmware / export / font.h
blobd17fa18b8bd3ecb47a1e7f3e344a1edff785124c
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_DIR"/.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 #ifndef __PCTOOL__
66 enum {
67 FONT_SYSFIXED, /* system fixed pitch font*/
68 FONT_UI, /* system porportional font*/
69 MAXFONTS
71 #endif
74 * .fnt loadable font file format definition
76 * format len description
77 * ------------------------- ---- ------------------------------
78 * UCHAR version[4] 4 magic number and version bytes
79 * USHORT maxwidth 2 font max width in pixels
80 * USHORT height 2 font height in pixels
81 * USHORT ascent 2 font ascent (baseline) in pixels
82 * USHORT pad 2 unused, pad to 32-bit boundary
83 * ULONG firstchar 4 first character code in font
84 * ULONG defaultchar 4 default character code in font
85 * ULONG size 4 # characters in font
86 * ULONG nbits 4 # bytes imagebits data in file
87 * ULONG noffset 4 # longs offset data in file
88 * ULONG nwidth 4 # bytes width data in file
89 * MWIMAGEBITS bits nbits image bits variable data
90 * [MWIMAGEBITS padded to 16-bit boundary]
91 * USHORT offset noffset*2 offset variable data
92 * UCHAR width nwidth*1 width variable data
95 /* loadable font magic and version #*/
96 #define VERSION "RB12"
98 /* builtin C-based proportional/fixed font structure */
99 /* based on The Microwindows Project http://microwindows.org */
100 struct font {
101 int maxwidth; /* max width in pixels*/
102 unsigned int height; /* height in pixels*/
103 int ascent; /* ascent (baseline) height*/
104 int firstchar; /* first character in bitmap*/
105 int size; /* font size in glyphs*/
106 const unsigned char *bits; /* 8-bit column bitmap data*/
107 const unsigned short *offset; /* offsets into bitmap data*/
108 const unsigned char *width; /* character widths or NULL if fixed*/
109 int defaultchar; /* default char (not glyph index)*/
110 int32_t bits_size; /* # bytes of glyph bits*/
113 /* font routines*/
114 void font_init(void);
115 struct font* font_load(const char *path);
116 struct font* font_get(int font);
117 void font_reset(void);
118 int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
119 int font_get_width(struct font* ft, unsigned short ch);
120 const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
121 void glyph_cache_save(void);
123 #else /* HAVE_LCD_BITMAP */
125 #define font_init()
126 #define font_load(x)
128 #endif
130 #endif