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 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Björn Stenberg | 0dcc4a6 | 2003-06-29 14:57:44 +0000 | [diff] [blame] | 21 | #ifndef _FONT_H |
| 22 | #define _FONT_H |
| 23 | |
Nils Wallménius | df155c8 | 2007-06-30 17:54:02 +0000 | [diff] [blame] | 24 | #include "inttypes.h" |
| 25 | |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 26 | /* |
| 27 | * Incore font and image definitions |
| 28 | */ |
| 29 | #include "config.h" |
| 30 | |
| 31 | #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) |
Dave Chapman | 7418c35 | 2008-03-25 21:09:58 +0000 | [diff] [blame] | 32 | #ifndef __PCTOOL__ |
Barry Wardell | 3f8d732 | 2007-01-17 12:34:56 +0000 | [diff] [blame] | 33 | #include "sysfont.h" |
Dave Chapman | 7418c35 | 2008-03-25 21:09:58 +0000 | [diff] [blame] | 34 | #endif |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 35 | |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 36 | /* max static loadable font buffer size */ |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 37 | #ifndef MAX_FONT_SIZE |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 38 | #if LCD_HEIGHT > 64 |
Linus Nielsen Feltzing | e06faa0 | 2007-03-05 08:32:35 +0000 | [diff] [blame] | 39 | #if MEM > 2 |
| 40 | #define MAX_FONT_SIZE 60000 |
| 41 | #else |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 42 | #define MAX_FONT_SIZE 10000 |
Linus Nielsen Feltzing | e06faa0 | 2007-03-05 08:32:35 +0000 | [diff] [blame] | 43 | #endif |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 44 | #else |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame] | 45 | #define MAX_FONT_SIZE 4000 |
Daniel Stenberg | 0f820d6 | 2005-08-03 21:31:51 +0000 | [diff] [blame] | 46 | #endif |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 47 | #endif |
| 48 | |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame] | 49 | #ifndef FONT_HEADER_SIZE |
| 50 | #define FONT_HEADER_SIZE 36 |
| 51 | #endif |
| 52 | |
| 53 | #define GLYPH_CACHE_FILE "/.rockbox/.glyphcache" |
| 54 | |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 55 | /* |
| 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. |
| 64 | */ |
| 65 | enum { |
| 66 | FONT_SYSFIXED, /* system fixed pitch font*/ |
| 67 | FONT_UI, /* system porportional font*/ |
| 68 | MAXFONTS |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * .fnt loadable font file format definition |
| 73 | * |
Jörg Hohensohn | a8dbabe | 2004-08-27 20:03:02 +0000 | [diff] [blame] | 74 | * format len description |
| 75 | * ------------------------- ---- ------------------------------ |
| 76 | * UCHAR version[4] 4 magic number and version bytes |
| 77 | * USHORT maxwidth 2 font max width in pixels |
| 78 | * USHORT height 2 font height in pixels |
| 79 | * USHORT ascent 2 font ascent (baseline) in pixels |
| 80 | * USHORT pad 2 unused, pad to 32-bit boundary |
| 81 | * ULONG firstchar 4 first character code in font |
| 82 | * ULONG defaultchar 4 default character code in font |
| 83 | * ULONG size 4 # characters in font |
| 84 | * ULONG nbits 4 # bytes imagebits data in file |
| 85 | * ULONG noffset 4 # longs offset data in file |
| 86 | * ULONG nwidth 4 # bytes width data in file |
| 87 | * MWIMAGEBITS bits nbits image bits variable data |
| 88 | * [MWIMAGEBITS padded to 16-bit boundary] |
| 89 | * USHORT offset noffset*2 offset variable data |
| 90 | * UCHAR width nwidth*1 width variable data |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 91 | */ |
| 92 | |
| 93 | /* loadable font magic and version #*/ |
Jörg Hohensohn | a8dbabe | 2004-08-27 20:03:02 +0000 | [diff] [blame] | 94 | #define VERSION "RB12" |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 95 | |
| 96 | /* builtin C-based proportional/fixed font structure */ |
| 97 | /* based on The Microwindows Project http://microwindows.org */ |
| 98 | struct font { |
Nils Wallménius | d718c27 | 2007-09-14 16:04:01 +0000 | [diff] [blame] | 99 | int maxwidth; /* max width in pixels*/ |
| 100 | unsigned int height; /* height in pixels*/ |
| 101 | int ascent; /* ascent (baseline) height*/ |
| 102 | int firstchar; /* first character in bitmap*/ |
| 103 | int size; /* font size in glyphs*/ |
| 104 | const unsigned char *bits; /* 8-bit column bitmap data*/ |
| 105 | const unsigned short *offset; /* offsets into bitmap data*/ |
| 106 | const unsigned char *width; /* character widths or NULL if fixed*/ |
| 107 | int defaultchar; /* default char (not glyph index)*/ |
| 108 | int32_t bits_size; /* # bytes of glyph bits*/ |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | /* font routines*/ |
| 112 | void font_init(void); |
Jens Arnold | c76c568 | 2004-08-16 23:37:23 +0000 | [diff] [blame] | 113 | struct font* font_load(const char *path); |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 114 | struct font* font_get(int font); |
| 115 | void font_reset(void); |
Christian Gmeiner | c6ec0f4 | 2005-04-19 12:47:16 +0000 | [diff] [blame] | 116 | 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] | 117 | int font_get_width(struct font* ft, unsigned short ch); |
| 118 | const unsigned char * font_get_bits(struct font* ft, unsigned short ch); |
| 119 | void glyph_cache_save(void); |
Daniel Stenberg | f9b4490 | 2003-02-07 09:41:57 +0000 | [diff] [blame] | 120 | |
| 121 | #else /* HAVE_LCD_BITMAP */ |
| 122 | |
| 123 | #define font_init() |
| 124 | #define font_load(x) |
| 125 | |
| 126 | #endif |
| 127 | |
Björn Stenberg | 0dcc4a6 | 2003-06-29 14:57:44 +0000 | [diff] [blame] | 128 | #endif |