fix warning
[maemo-rb.git] / firmware / export / font.h
blob1e50faa6cf4578e7565353af4c3b876946411b3b
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 <stdlib.h>
25 #include "inttypes.h"
26 #include "stdbool.h"
29 * Incore font and image definitions
31 #include "config.h"
33 #if defined(HAVE_LCD_BITMAP) || (CONFIG_PLATFORM & PLATFORM_HOSTED)
34 #ifndef __PCTOOL__
35 #include "font_cache.h"
36 #include "sysfont.h"
37 #endif
41 * Fonts are specified by number, and used for display
42 * of menu information as well as mp3 filename data.
43 * At system startup, up to MAXFONTS fonts are initialized,
44 * either by being compiled-in, or loaded from disk.
45 * If the font asked for does not exist, then the
46 * system uses the next lower font number. Font 0
47 * must be available at system startup.
48 * Fonts are specified in firmware/font.c.
50 enum {
51 FONT_SYSFIXED = -1, /* system fixed pitch font*/
52 FONT_FIRSTUSERFONT = 0, /* first id for the user fonts */
54 #define MAXUSERFONTS 8
56 /* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */
57 #define MAXFONTS (FONT_FIRSTUSERFONT + MAXUSERFONTS)
58 #define FONT_UI MAXFONTS
61 * .fnt loadable font file format definition
63 * format len description
64 * ------------------------- ---- ------------------------------
65 * UCHAR version[4] 4 magic number and version bytes
66 * USHORT maxwidth 2 font max width in pixels
67 * USHORT height 2 font height in pixels
68 * USHORT ascent 2 font ascent (baseline) in pixels
69 * USHORT depth 2 depth of the font, 0=1bit and 1=4bit
70 * ULONG firstchar 4 first character code in font
71 * ULONG defaultchar 4 default character code in font
72 * ULONG size 4 # characters in font
73 * ULONG nbits 4 # bytes imagebits data in file
74 * ULONG noffset 4 # longs offset data in file
75 * ULONG nwidth 4 # bytes width data in file
76 * MWIMAGEBITS bits nbits image bits variable data
77 * [MWIMAGEBITS padded to 16-bit boundary]
78 * USHORT offset noffset*2 offset variable data
79 * UCHAR width nwidth*1 width variable data
82 /* loadable font magic and version #*/
83 #define VERSION "RB12"
85 /* builtin C-based proportional/fixed font structure */
86 /* based on The Microwindows Project http://microwindows.org */
87 struct font {
88 int maxwidth; /* max width in pixels*/
89 unsigned int height; /* height in pixels*/
90 int ascent; /* ascent (baseline) height*/
91 int firstchar; /* first character in bitmap*/
92 int size; /* font size in glyphs*/
93 int depth; /* depth of the font, 0=1bit and 1=4bit */
94 const unsigned char *bits; /* 8-bit column bitmap data*/
95 const void *offset; /* offsets into bitmap data,
96 uint16_t if bits_size < 0xFFDB else uint32_t*/
97 const unsigned char *width; /* character widths or NULL if fixed*/
98 int defaultchar; /* default char (not glyph index)*/
99 int32_t bits_size; /* # bytes of glyph bits*/
101 /* file, buffer and cache management */
102 int fd; /* fd for the font file. >= 0 if cached */
103 int fd_width; /* fd for the font file. >= 0 if cached */
104 int fd_offset; /* fd for the font file. >= 0 if cached */
105 int handle; /* core_allocator handle */
106 unsigned char *buffer_start; /* buffer to store the font in */
107 unsigned char *buffer_position; /* position in the buffer */
108 unsigned char *buffer_end; /* end of the buffer */
109 size_t buffer_size; /* size of the buffer in bytes */
110 #ifndef __PCTOOL__
111 struct font_cache cache;
112 uint32_t file_width_offset; /* offset to file width data */
113 uint32_t file_offset_offset; /* offset to file offset data */
114 int long_offset;
115 #endif
119 /* font routines*/
120 void font_init(void) INIT_ATTR;
121 const char* font_filename(int font_id);
122 int font_load(const char *path);
123 int font_load_ex(const char *path, size_t buffer_size, int glyphs);
124 void font_unload(int font_id);
125 void font_unload_all(void);
126 void font_lock(int font_id, bool lock);
128 struct font* font_get(int font);
130 int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
131 int font_get_width(struct font* ft, unsigned short ch);
132 const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
134 #else /* HAVE_LCD_BITMAP */
136 #define font_init()
137 #define font_load(x)
139 #endif
141 #endif