Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 Stenberg | 0dcc4a6 | 2003-06-29 14:57:44 +0000 | [diff] [blame] | 19 | #ifndef _FONT_H |
| 20 | #define _FONT_H |
| 21 | |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 22 | /* |
| 23 | * Incore font and image definitions |
| 24 | */ |
| 25 | #include "config.h" |
| 26 | |
| 27 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) |
Barry Wardell | 3f8d732 | 2007-01-17 12:34:56 +0000 | [diff] [blame] | 28 | #include "sysfont.h" |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 29 | |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 30 | /* max static loadable font buffer size */ |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 31 | #ifndef MAX_FONT_SIZE |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 32 | #if LCD_HEIGHT > 64 |
Linus Nielsen Feltzing | e06faa0 | 2007-03-05 08:32:35 +0000 | [diff] [blame] | 33 | #if MEM > 2 |
| 34 | #define MAX_FONT_SIZE 60000 |
| 35 | #else |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 36 | #define MAX_FONT_SIZE 10000 |
Linus Nielsen Feltzing | e06faa0 | 2007-03-05 08:32:35 +0000 | [diff] [blame] | 37 | #endif |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 38 | #else |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame] | 39 | #define MAX_FONT_SIZE 4000 |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 40 | #endif |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 41 | #endif |
| 42 | |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame] | 43 | #ifndef FONT_HEADER_SIZE |
| 44 | #define FONT_HEADER_SIZE 36 |
| 45 | #endif |
| 46 | |
| 47 | #define GLYPH_CACHE_FILE "/.rockbox/.glyphcache" |
| 48 | |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 49 | /* |
| 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 | */ |
| 59 | enum { |
| 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 Hohensohn | a8dbabe | 2004-08-27 20:03:02 +0000 | [diff] [blame] | 68 | * 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 Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 85 | */ |
| 86 | |
| 87 | /* loadable font magic and version #*/ |
Jörg Hohensohn | a8dbabe | 2004-08-27 20:03:02 +0000 | [diff] [blame] | 88 | #define VERSION "RB12" |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 89 | |
| 90 | /* builtin C-based proportional/fixed font structure */ |
| 91 | /* based on The Microwindows Project http://microwindows.org */ |
| 92 | struct font { |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 93 | 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 Hohensohn | 5d36aaf | 2004-08-26 21:15:07 +0000 | [diff] [blame] | 98 | 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 Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 101 | int defaultchar; /* default char (not glyph index)*/ |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame] | 102 | long bits_size; /* # bytes of glyph bits*/ |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | /* font routines*/ |
| 106 | void font_init(void); |
Jens Arnold | c76c568 | 2004-08-16 23:37:23 +0000 | [diff] [blame] | 107 | struct font* font_load(const char *path); |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 108 | struct font* font_get(int font); |
| 109 | void font_reset(void); |
Christian Gmeiner | c6ec0f4 | 2005-04-19 12:47:16 +0000 | [diff] [blame] | 110 | int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber); |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame] | 111 | int font_get_width(struct font* ft, unsigned short ch); |
| 112 | const unsigned char * font_get_bits(struct font* ft, unsigned short ch); |
| 113 | void glyph_cache_save(void); |
| 114 | void glyph_cache_load(void); |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 115 | |
| 116 | #else /* HAVE_LCD_BITMAP */ |
| 117 | |
| 118 | #define font_init() |
| 119 | #define font_load(x) |
| 120 | |
| 121 | #endif |
| 122 | |
Björn Stenberg | 0dcc4a6 | 2003-06-29 14:57:44 +0000 | [diff] [blame] | 123 | #endif |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 124 | /* ----------------------------------------------------------------- |
| 125 | * vim: et sw=4 ts=8 sts=4 tw=78 |
| 126 | */ |