2003-02-07 09:41:57 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2003-02-07 09:41:57 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2011-09-24 14:52:16 +00:00
|
|
|
#include <stdlib.h>
|
2007-06-30 17:54:02 +00:00
|
|
|
#include "inttypes.h"
|
2011-09-24 13:19:34 +00:00
|
|
|
#include "stdbool.h"
|
2007-06-30 17:54:02 +00:00
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
* Incore font and image definitions
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
2010-06-21 16:53:00 +00:00
|
|
|
#if defined(HAVE_LCD_BITMAP) || (CONFIG_PLATFORM & PLATFORM_HOSTED)
|
2008-03-25 21:09:58 +00:00
|
|
|
#ifndef __PCTOOL__
|
2010-02-14 06:26:16 +00:00
|
|
|
#include "font_cache.h"
|
2007-01-17 12:34:56 +00:00
|
|
|
#include "sysfont.h"
|
2008-03-25 21:09:58 +00:00
|
|
|
#endif
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
|
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 {
|
2011-09-24 13:19:34 +00:00
|
|
|
FONT_SYSFIXED = -1, /* system fixed pitch font*/
|
|
|
|
FONT_FIRSTUSERFONT = 0, /* first id for the user fonts */
|
2003-02-07 09:41:57 +00:00
|
|
|
};
|
2010-03-03 00:53:07 +00:00
|
|
|
#define MAXUSERFONTS 8
|
2003-02-07 09:41:57 +00:00
|
|
|
|
2010-03-03 00:53:07 +00:00
|
|
|
/* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */
|
2011-09-24 13:19:34 +00:00
|
|
|
#define MAXFONTS (FONT_FIRSTUSERFONT + MAXUSERFONTS)
|
2011-11-08 10:09:33 +00:00
|
|
|
#define FONT_UI MAXFONTS
|
2010-02-14 06:26:16 +00:00
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
/*
|
|
|
|
* .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
|
2011-03-05 18:36:51 +00:00
|
|
|
* USHORT depth 2 depth of the font, 0=1bit and 1=4bit
|
2004-08-27 20:03:02 +00:00
|
|
|
* 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 {
|
2007-09-14 16:04:01 +00:00
|
|
|
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*/
|
2011-03-05 18:36:51 +00:00
|
|
|
int depth; /* depth of the font, 0=1bit and 1=4bit */
|
2007-09-14 16:04:01 +00:00
|
|
|
const unsigned char *bits; /* 8-bit column bitmap data*/
|
2009-12-13 11:07:40 +00:00
|
|
|
const void *offset; /* offsets into bitmap data,
|
|
|
|
uint16_t if bits_size < 0xFFDB else uint32_t*/
|
2007-09-14 16:04:01 +00:00
|
|
|
const unsigned char *width; /* character widths or NULL if fixed*/
|
|
|
|
int defaultchar; /* default char (not glyph index)*/
|
|
|
|
int32_t bits_size; /* # bytes of glyph bits*/
|
2010-02-14 06:26:16 +00:00
|
|
|
|
|
|
|
/* file, buffer and cache management */
|
|
|
|
int fd; /* fd for the font file. >= 0 if cached */
|
2011-10-17 13:17:04 +00:00
|
|
|
int fd_width; /* fd for the font file. >= 0 if cached */
|
|
|
|
int fd_offset; /* fd for the font file. >= 0 if cached */
|
2010-02-14 06:26:16 +00:00
|
|
|
unsigned char *buffer_start; /* buffer to store the font in */
|
|
|
|
unsigned char *buffer_position; /* position in the buffer */
|
|
|
|
unsigned char *buffer_end; /* end of the buffer */
|
2011-09-24 14:52:16 +00:00
|
|
|
size_t buffer_size; /* size of the buffer in bytes */
|
2010-02-14 06:26:16 +00:00
|
|
|
#ifndef __PCTOOL__
|
|
|
|
struct font_cache cache;
|
|
|
|
uint32_t file_width_offset; /* offset to file width data */
|
|
|
|
uint32_t file_offset_offset; /* offset to file offset data */
|
|
|
|
int long_offset;
|
|
|
|
#endif
|
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* font routines*/
|
2010-03-03 23:20:32 +00:00
|
|
|
void font_init(void) INIT_ATTR;
|
2011-09-24 13:19:34 +00:00
|
|
|
const char* font_filename(int font_id);
|
|
|
|
int font_load(const char *path);
|
2011-09-24 14:52:16 +00:00
|
|
|
int font_load_ex(const char *path, size_t buffer_size);
|
2010-08-27 18:25:23 +00:00
|
|
|
int font_glyphs_to_bufsize(const char *path, int glyphs);
|
2010-02-14 06:26:16 +00:00
|
|
|
void font_unload(int font_id);
|
2011-10-16 13:28:44 +00:00
|
|
|
void font_unload_all(void);
|
2011-10-21 18:05:52 +00:00
|
|
|
void font_lock(int font_id, bool lock);
|
2010-02-14 06:26:16 +00:00
|
|
|
|
2003-02-07 09:41:57 +00:00
|
|
|
struct font* font_get(int font);
|
2010-02-14 06:26:16 +00:00
|
|
|
|
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);
|
2011-10-16 13:18:46 +00:00
|
|
|
void glyph_cache_save(int font_id);
|
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
|