2003-02-07 09:41:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2003-06-29 14:57:44 +00:00
|
|
|
#ifndef _FONT_H
|
|
|
|
#define _FONT_H
|
|
|
|
|
2007-06-30 17:54:02 +00:00
|
|
|
#include "inttypes.h"
|
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
* Incore font and image definitions
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
|
2007-01-17 12:34:56 +00:00
|
|
|
#include "sysfont.h"
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2005-08-03 21:31:51 +00:00
|
|
|
/* max static loadable font buffer size */
|
2003-02-07 09:41:57 +00:00
|
|
|
#ifndef MAX_FONT_SIZE
|
2005-08-03 21:31:51 +00:00
|
|
|
#if LCD_HEIGHT > 64
|
2007-03-05 08:32:35 +00:00
|
|
|
#if MEM > 2
|
|
|
|
#define MAX_FONT_SIZE 60000
|
|
|
|
#else
|
2005-08-03 21:31:51 +00:00
|
|
|
#define MAX_FONT_SIZE 10000
|
2007-03-05 08:32:35 +00:00
|
|
|
#endif
|
2005-08-03 21:31:51 +00:00
|
|
|
#else
|
2005-12-06 13:27:15 +00:00
|
|
|
#define MAX_FONT_SIZE 4000
|
2005-08-03 21:31:51 +00:00
|
|
|
#endif
|
2003-02-07 09:41:57 +00:00
|
|
|
#endif
|
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
#ifndef FONT_HEADER_SIZE
|
|
|
|
#define FONT_HEADER_SIZE 36
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GLYPH_CACHE_FILE "/.rockbox/.glyphcache"
|
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
* Fonts are specified by number, and used for display
|
|
|
|
* of menu information as well as mp3 filename data.
|
|
|
|
* At system startup, up to MAXFONTS fonts are initialized,
|
|
|
|
* either by being compiled-in, or loaded from disk.
|
|
|
|
* If the font asked for does not exist, then the
|
|
|
|
* system uses the next lower font number. Font 0
|
|
|
|
* must be available at system startup.
|
|
|
|
* Fonts are specified in firmware/font.c.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
FONT_SYSFIXED, /* system fixed pitch font*/
|
|
|
|
FONT_UI, /* system porportional font*/
|
|
|
|
MAXFONTS
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* .fnt loadable font file format definition
|
|
|
|
*
|
2004-08-27 20:03:02 +00:00
|
|
|
* format len description
|
|
|
|
* ------------------------- ---- ------------------------------
|
|
|
|
* UCHAR version[4] 4 magic number and version bytes
|
|
|
|
* USHORT maxwidth 2 font max width in pixels
|
|
|
|
* USHORT height 2 font height in pixels
|
|
|
|
* USHORT ascent 2 font ascent (baseline) in pixels
|
|
|
|
* USHORT pad 2 unused, pad to 32-bit boundary
|
|
|
|
* ULONG firstchar 4 first character code in font
|
|
|
|
* ULONG defaultchar 4 default character code in font
|
|
|
|
* ULONG size 4 # characters in font
|
|
|
|
* ULONG nbits 4 # bytes imagebits data in file
|
|
|
|
* ULONG noffset 4 # longs offset data in file
|
|
|
|
* ULONG nwidth 4 # bytes width data in file
|
|
|
|
* MWIMAGEBITS bits nbits image bits variable data
|
|
|
|
* [MWIMAGEBITS padded to 16-bit boundary]
|
|
|
|
* USHORT offset noffset*2 offset variable data
|
|
|
|
* UCHAR width nwidth*1 width variable data
|
2003-02-07 09:41:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* loadable font magic and version #*/
|
2004-08-27 20:03:02 +00:00
|
|
|
#define VERSION "RB12"
|
2003-02-07 09:41:57 +00:00
|
|
|
|
|
|
|
/* builtin C-based proportional/fixed font structure */
|
|
|
|
/* based on The Microwindows Project http://microwindows.org */
|
|
|
|
struct font {
|
|
|
|
int maxwidth; /* max width in pixels*/
|
|
|
|
unsigned int height; /* height in pixels*/
|
|
|
|
int ascent; /* ascent (baseline) height*/
|
|
|
|
int firstchar; /* first character in bitmap*/
|
|
|
|
int size; /* font size in glyphs*/
|
2004-08-26 21:15:07 +00:00
|
|
|
const unsigned char *bits; /* 8-bit column bitmap data*/
|
|
|
|
const unsigned short *offset; /* offsets into bitmap data*/
|
|
|
|
const unsigned char *width; /* character widths or NULL if fixed*/
|
2003-02-07 09:41:57 +00:00
|
|
|
int defaultchar; /* default char (not glyph index)*/
|
2007-06-30 17:54:02 +00:00
|
|
|
int32_t bits_size; /* # bytes of glyph bits*/
|
2003-02-07 09:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* font routines*/
|
|
|
|
void font_init(void);
|
2004-08-16 23:37:23 +00:00
|
|
|
struct font* font_load(const char *path);
|
2003-02-07 09:41:57 +00:00
|
|
|
struct font* font_get(int font);
|
|
|
|
void font_reset(void);
|
2005-04-19 12:47:16 +00:00
|
|
|
int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
|
2005-12-06 13:27:15 +00:00
|
|
|
int font_get_width(struct font* ft, unsigned short ch);
|
|
|
|
const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
|
|
|
|
void glyph_cache_save(void);
|
2003-02-07 09:41:57 +00:00
|
|
|
|
|
|
|
#else /* HAVE_LCD_BITMAP */
|
|
|
|
|
|
|
|
#define font_init()
|
|
|
|
#define font_load(x)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2003-06-29 14:57:44 +00:00
|
|
|
#endif
|
2003-02-07 09:41:57 +00:00
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
* vim: et sw=4 ts=8 sts=4 tw=78
|
|
|
|
*/
|