blob: 57991a5d507768ef4f8a14efe58be7957a002ea4 [file] [log] [blame]
Daniel Stenbergf9b44902003-02-07 09:41:57 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
Björn Stenberg0dcc4a62003-06-29 14:57:44 +000019#ifndef _FONT_H
20#define _FONT_H
21
Daniel Stenbergf9b44902003-02-07 09:41:57 +000022/*
23 * Incore font and image definitions
24 */
25#include "config.h"
26
27#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
Barry Wardell3f8d7322007-01-17 12:34:56 +000028#include "sysfont.h"
Daniel Stenbergf9b44902003-02-07 09:41:57 +000029
Daniel Stenberg0f820d62005-08-03 21:31:51 +000030/* max static loadable font buffer size */
Daniel Stenbergf9b44902003-02-07 09:41:57 +000031#ifndef MAX_FONT_SIZE
Daniel Stenberg0f820d62005-08-03 21:31:51 +000032#if LCD_HEIGHT > 64
Linus Nielsen Feltzinge06faa02007-03-05 08:32:35 +000033#if MEM > 2
34#define MAX_FONT_SIZE 60000
35#else
Daniel Stenberg0f820d62005-08-03 21:31:51 +000036#define MAX_FONT_SIZE 10000
Linus Nielsen Feltzinge06faa02007-03-05 08:32:35 +000037#endif
Daniel Stenberg0f820d62005-08-03 21:31:51 +000038#else
Marcoen Hirschbergb0fee172005-12-06 13:27:15 +000039#define MAX_FONT_SIZE 4000
Daniel Stenberg0f820d62005-08-03 21:31:51 +000040#endif
Daniel Stenbergf9b44902003-02-07 09:41:57 +000041#endif
42
Marcoen Hirschbergb0fee172005-12-06 13:27:15 +000043#ifndef FONT_HEADER_SIZE
44#define FONT_HEADER_SIZE 36
45#endif
46
47#define GLYPH_CACHE_FILE "/.rockbox/.glyphcache"
48
Daniel Stenbergf9b44902003-02-07 09:41:57 +000049/*
50 * Fonts are specified by number, and used for display
51 * of menu information as well as mp3 filename data.
52 * At system startup, up to MAXFONTS fonts are initialized,
53 * either by being compiled-in, or loaded from disk.
54 * If the font asked for does not exist, then the
55 * system uses the next lower font number. Font 0
56 * must be available at system startup.
57 * Fonts are specified in firmware/font.c.
58 */
59enum {
60 FONT_SYSFIXED, /* system fixed pitch font*/
61 FONT_UI, /* system porportional font*/
62 MAXFONTS
63};
64
65/*
66 * .fnt loadable font file format definition
67 *
Jörg Hohensohna8dbabe2004-08-27 20:03:02 +000068 * format len description
69 * ------------------------- ---- ------------------------------
70 * UCHAR version[4] 4 magic number and version bytes
71 * USHORT maxwidth 2 font max width in pixels
72 * USHORT height 2 font height in pixels
73 * USHORT ascent 2 font ascent (baseline) in pixels
74 * USHORT pad 2 unused, pad to 32-bit boundary
75 * ULONG firstchar 4 first character code in font
76 * ULONG defaultchar 4 default character code in font
77 * ULONG size 4 # characters in font
78 * ULONG nbits 4 # bytes imagebits data in file
79 * ULONG noffset 4 # longs offset data in file
80 * ULONG nwidth 4 # bytes width data in file
81 * MWIMAGEBITS bits nbits image bits variable data
82 * [MWIMAGEBITS padded to 16-bit boundary]
83 * USHORT offset noffset*2 offset variable data
84 * UCHAR width nwidth*1 width variable data
Daniel Stenbergf9b44902003-02-07 09:41:57 +000085 */
86
87/* loadable font magic and version #*/
Jörg Hohensohna8dbabe2004-08-27 20:03:02 +000088#define VERSION "RB12"
Daniel Stenbergf9b44902003-02-07 09:41:57 +000089
90/* builtin C-based proportional/fixed font structure */
91/* based on The Microwindows Project http://microwindows.org */
92struct font {
Daniel Stenbergf9b44902003-02-07 09:41:57 +000093 int maxwidth; /* max width in pixels*/
94 unsigned int height; /* height in pixels*/
95 int ascent; /* ascent (baseline) height*/
96 int firstchar; /* first character in bitmap*/
97 int size; /* font size in glyphs*/
Jörg Hohensohn5d36aaf2004-08-26 21:15:07 +000098 const unsigned char *bits; /* 8-bit column bitmap data*/
99 const unsigned short *offset; /* offsets into bitmap data*/
100 const unsigned char *width; /* character widths or NULL if fixed*/
Daniel Stenbergf9b44902003-02-07 09:41:57 +0000101 int defaultchar; /* default char (not glyph index)*/
Marcoen Hirschbergb0fee172005-12-06 13:27:15 +0000102 long bits_size; /* # bytes of glyph bits*/
Daniel Stenbergf9b44902003-02-07 09:41:57 +0000103};
104
105/* font routines*/
106void font_init(void);
Jens Arnoldc76c5682004-08-16 23:37:23 +0000107struct font* font_load(const char *path);
Daniel Stenbergf9b44902003-02-07 09:41:57 +0000108struct font* font_get(int font);
109void font_reset(void);
Christian Gmeinerc6ec0f42005-04-19 12:47:16 +0000110int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
Marcoen Hirschbergb0fee172005-12-06 13:27:15 +0000111int font_get_width(struct font* ft, unsigned short ch);
112const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
113void glyph_cache_save(void);
114void glyph_cache_load(void);
Daniel Stenbergf9b44902003-02-07 09:41:57 +0000115
116#else /* HAVE_LCD_BITMAP */
117
118#define font_init()
119#define font_load(x)
120
121#endif
122
Björn Stenberg0dcc4a62003-06-29 14:57:44 +0000123#endif
Daniel Stenbergf9b44902003-02-07 09:41:57 +0000124/* -----------------------------------------------------------------
125 * vim: et sw=4 ts=8 sts=4 tw=78
126 */