We have a 3.9 release, update builds.pm
[maemo-rb.git] / firmware / export / font.h
bloba85f95e6ae940de8e1a0af113875783075d04d40
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) || (CONFIG_PLATFORM & PLATFORM_HOSTED)
32 #ifndef __PCTOOL__
33 #include "font_cache.h"
34 #include "sysfont.h"
35 #endif
39 * Fonts are specified by number, and used for display
40 * of menu information as well as mp3 filename data.
41 * At system startup, up to MAXFONTS fonts are initialized,
42 * either by being compiled-in, or loaded from disk.
43 * If the font asked for does not exist, then the
44 * system uses the next lower font number. Font 0
45 * must be available at system startup.
46 * Fonts are specified in firmware/font.c.
48 enum {
49 FONT_SYSFIXED, /* system fixed pitch font*/
50 FONT_UI, /* system porportional font*/
51 #ifdef HAVE_REMOTE_LCD
52 FONT_UI_REMOTE, /* UI font for remote LCD */
53 #endif
54 SYSTEMFONTCOUNT, /* Number of fonts reserved for the system and ui */
55 FONT_FIRSTUSERFONT = 2
57 #define MAXUSERFONTS 8
59 /* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */
60 #define MAXFONTS (SYSTEMFONTCOUNT + MAXUSERFONTS)
63 * .fnt loadable font file format definition
65 * format len description
66 * ------------------------- ---- ------------------------------
67 * UCHAR version[4] 4 magic number and version bytes
68 * USHORT maxwidth 2 font max width in pixels
69 * USHORT height 2 font height in pixels
70 * USHORT ascent 2 font ascent (baseline) in pixels
71 * USHORT depth 2 depth of the font, 0=1bit and 1=4bit
72 * ULONG firstchar 4 first character code in font
73 * ULONG defaultchar 4 default character code in font
74 * ULONG size 4 # characters in font
75 * ULONG nbits 4 # bytes imagebits data in file
76 * ULONG noffset 4 # longs offset data in file
77 * ULONG nwidth 4 # bytes width data in file
78 * MWIMAGEBITS bits nbits image bits variable data
79 * [MWIMAGEBITS padded to 16-bit boundary]
80 * USHORT offset noffset*2 offset variable data
81 * UCHAR width nwidth*1 width variable data
84 /* loadable font magic and version #*/
85 #define VERSION "RB12"
87 /* builtin C-based proportional/fixed font structure */
88 /* based on The Microwindows Project http://microwindows.org */
89 struct font {
90 int maxwidth; /* max width in pixels*/
91 unsigned int height; /* height in pixels*/
92 int ascent; /* ascent (baseline) height*/
93 int firstchar; /* first character in bitmap*/
94 int size; /* font size in glyphs*/
95 int depth; /* depth of the font, 0=1bit and 1=4bit */
96 const unsigned char *bits; /* 8-bit column bitmap data*/
97 const void *offset; /* offsets into bitmap data,
98 uint16_t if bits_size < 0xFFDB else uint32_t*/
99 const unsigned char *width; /* character widths or NULL if fixed*/
100 int defaultchar; /* default char (not glyph index)*/
101 int32_t bits_size; /* # bytes of glyph bits*/
103 /* file, buffer and cache management */
104 int fd; /* fd for the font file. >= 0 if cached */
105 unsigned char *buffer_start; /* buffer to store the font in */
106 unsigned char *buffer_position; /* position in the buffer */
107 unsigned char *buffer_end; /* end of the buffer */
108 int buffer_size; /* size of the buffer in bytes */
109 #ifndef __PCTOOL__
110 struct font_cache cache;
111 uint32_t file_width_offset; /* offset to file width data */
112 uint32_t file_offset_offset; /* offset to file offset data */
113 int long_offset;
114 #endif
118 /* font routines*/
119 void font_init(void) INIT_ATTR;
120 #ifdef HAVE_REMOTE_LCD
121 /* Load a font into the special remote ui font slot */
122 int font_load_remoteui(const char* path);
123 #endif
124 int font_load(struct font* pf, const char *path);
125 int font_glyphs_to_bufsize(const char *path, int glyphs);
126 void font_unload(int font_id);
128 struct font* font_get(int font);
130 void font_reset(struct font *pf);
131 int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
132 int font_get_width(struct font* ft, unsigned short ch);
133 const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
134 void glyph_cache_save(struct font* pf);
136 #else /* HAVE_LCD_BITMAP */
138 #define font_init()
139 #define font_load(x)
141 #endif
143 #endif