2002-09-12 13:33:59 +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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
/*
|
|
|
|
* Incore font and image definitions
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
|
|
|
|
|
|
|
|
/* max static loadable fonts buffer*/
|
|
|
|
#ifndef MAX_FONT_SIZE
|
|
|
|
#define MAX_FONT_SIZE 9000 /* max total fontsize allocation*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2002-09-20 08:07:51 +00:00
|
|
|
enum {
|
|
|
|
FONT_SYSFIXED, /* system fixed pitch font*/
|
|
|
|
FONT_UI, /* system porportional font*/
|
|
|
|
MAXFONTS
|
|
|
|
};
|
2002-09-12 13:33:59 +00:00
|
|
|
|
|
|
|
/*
|
2002-09-20 08:07:51 +00:00
|
|
|
* .fnt loadable font file format definition
|
2002-09-12 13:33:59 +00:00
|
|
|
*
|
Daniel,
The following patch makes loadable fonts actually work (finally!).
It took me quite a while, but I finally figured out why the sim
worked and the target didn't: the SH1 processor won't read
longwords from a shortword alignment... I had to rev the .fnt
file to version 1.1 (requires remaking *.fnt files) in order
to fix this. Please apply the following patch completely.
It's diffed against the latest CVS.
I've also attached rockbox-fonts-1.1.tar.gz which includes
known working *.fnt files, including a courB08 system.fnt,
for demonstration.
Now the real work can begin... Although the new
system.fnt will work fine, if you try going to a really
big font (try copying courB14.fnt to system.fnt), then
you will find that it comes up and works in tree mode,
but will crash the system when going into WPS
mode... I'm sure this is because of the low-level
lcd_bitmap not clipping properly when given a too-large
bitmap, which the characters become. I haven't yet
tried to debug the low-level driver. Of course, it all
works on the sim...
So the apps developers will now have to make sure that
all apps screen sizes may vary according to the loaded font.
The font height can be gotten through the lcd_getfontsize API.
Files patched in fonts-6.patch
1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin)
2. firmware/font.c - fixes and reformatting. Please check this in as is,
my vi editor requires more reformatting changes since I left tabs in the
file, these are removed now (2nd resubmission on this, please checkin)
3. firmware/fonts.h - doc change on .fnt file format, .fnt version
number incremented.
4. firmware/loadfont.c - fixes to load font properly, typedefs
removed.
5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before
issuing error, otherwise font may not exist.
6. tools/bdf2c - fixes for correct output when filename starts
with a number, as well as when no DEFAULT_CHAR in .bdf
file. (2nd resubmission on this, please checkin)
7. tools/writerbf.c - fixes for bugfixed fontfile format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
2002-09-16 03:18:49 +00:00
|
|
|
* format len description
|
2002-09-12 13:33:59 +00:00
|
|
|
* ------------------------- ---- ------------------------------
|
|
|
|
* UCHAR version[4] 4 magic number and version bytes
|
|
|
|
* UCHAR name[64] 64 font name, space padded
|
|
|
|
* UCHAR copyright[256] 256 copyright info, space padded
|
|
|
|
* USHORT maxwidth 2 font max width in pixels
|
|
|
|
* USHORT height 2 font height in pixels
|
|
|
|
* USHORT ascent 2 font ascent (baseline) in pixels
|
Daniel,
The following patch makes loadable fonts actually work (finally!).
It took me quite a while, but I finally figured out why the sim
worked and the target didn't: the SH1 processor won't read
longwords from a shortword alignment... I had to rev the .fnt
file to version 1.1 (requires remaking *.fnt files) in order
to fix this. Please apply the following patch completely.
It's diffed against the latest CVS.
I've also attached rockbox-fonts-1.1.tar.gz which includes
known working *.fnt files, including a courB08 system.fnt,
for demonstration.
Now the real work can begin... Although the new
system.fnt will work fine, if you try going to a really
big font (try copying courB14.fnt to system.fnt), then
you will find that it comes up and works in tree mode,
but will crash the system when going into WPS
mode... I'm sure this is because of the low-level
lcd_bitmap not clipping properly when given a too-large
bitmap, which the characters become. I haven't yet
tried to debug the low-level driver. Of course, it all
works on the sim...
So the apps developers will now have to make sure that
all apps screen sizes may vary according to the loaded font.
The font height can be gotten through the lcd_getfontsize API.
Files patched in fonts-6.patch
1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin)
2. firmware/font.c - fixes and reformatting. Please check this in as is,
my vi editor requires more reformatting changes since I left tabs in the
file, these are removed now (2nd resubmission on this, please checkin)
3. firmware/fonts.h - doc change on .fnt file format, .fnt version
number incremented.
4. firmware/loadfont.c - fixes to load font properly, typedefs
removed.
5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before
issuing error, otherwise font may not exist.
6. tools/bdf2c - fixes for correct output when filename starts
with a number, as well as when no DEFAULT_CHAR in .bdf
file. (2nd resubmission on this, please checkin)
7. tools/writerbf.c - fixes for bugfixed fontfile format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
2002-09-16 03:18:49 +00:00
|
|
|
* USHORT pad 2 unused, pad to 32-bit boundary
|
2002-09-12 13:33:59 +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 # words imagebits data in file
|
|
|
|
* ULONG noffset 4 # longs offset data in file
|
|
|
|
* ULONG nwidth 4 # bytes width data in file
|
|
|
|
* MWIMAGEBITS bits nbits*2 image bits variable data
|
Daniel,
The following patch makes loadable fonts actually work (finally!).
It took me quite a while, but I finally figured out why the sim
worked and the target didn't: the SH1 processor won't read
longwords from a shortword alignment... I had to rev the .fnt
file to version 1.1 (requires remaking *.fnt files) in order
to fix this. Please apply the following patch completely.
It's diffed against the latest CVS.
I've also attached rockbox-fonts-1.1.tar.gz which includes
known working *.fnt files, including a courB08 system.fnt,
for demonstration.
Now the real work can begin... Although the new
system.fnt will work fine, if you try going to a really
big font (try copying courB14.fnt to system.fnt), then
you will find that it comes up and works in tree mode,
but will crash the system when going into WPS
mode... I'm sure this is because of the low-level
lcd_bitmap not clipping properly when given a too-large
bitmap, which the characters become. I haven't yet
tried to debug the low-level driver. Of course, it all
works on the sim...
So the apps developers will now have to make sure that
all apps screen sizes may vary according to the loaded font.
The font height can be gotten through the lcd_getfontsize API.
Files patched in fonts-6.patch
1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin)
2. firmware/font.c - fixes and reformatting. Please check this in as is,
my vi editor requires more reformatting changes since I left tabs in the
file, these are removed now (2nd resubmission on this, please checkin)
3. firmware/fonts.h - doc change on .fnt file format, .fnt version
number incremented.
4. firmware/loadfont.c - fixes to load font properly, typedefs
removed.
5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before
issuing error, otherwise font may not exist.
6. tools/bdf2c - fixes for correct output when filename starts
with a number, as well as when no DEFAULT_CHAR in .bdf
file. (2nd resubmission on this, please checkin)
7. tools/writerbf.c - fixes for bugfixed fontfile format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
2002-09-16 03:18:49 +00:00
|
|
|
* [MWIMAGEBITS padded to 32-bit boundary]
|
2002-09-12 13:33:59 +00:00
|
|
|
* ULONG offset noffset*4 offset variable data
|
|
|
|
* UCHAR width nwidth*1 width variable data
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* loadable font magic and version #*/
|
Daniel,
The following patch makes loadable fonts actually work (finally!).
It took me quite a while, but I finally figured out why the sim
worked and the target didn't: the SH1 processor won't read
longwords from a shortword alignment... I had to rev the .fnt
file to version 1.1 (requires remaking *.fnt files) in order
to fix this. Please apply the following patch completely.
It's diffed against the latest CVS.
I've also attached rockbox-fonts-1.1.tar.gz which includes
known working *.fnt files, including a courB08 system.fnt,
for demonstration.
Now the real work can begin... Although the new
system.fnt will work fine, if you try going to a really
big font (try copying courB14.fnt to system.fnt), then
you will find that it comes up and works in tree mode,
but will crash the system when going into WPS
mode... I'm sure this is because of the low-level
lcd_bitmap not clipping properly when given a too-large
bitmap, which the characters become. I haven't yet
tried to debug the low-level driver. Of course, it all
works on the sim...
So the apps developers will now have to make sure that
all apps screen sizes may vary according to the loaded font.
The font height can be gotten through the lcd_getfontsize API.
Files patched in fonts-6.patch
1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin)
2. firmware/font.c - fixes and reformatting. Please check this in as is,
my vi editor requires more reformatting changes since I left tabs in the
file, these are removed now (2nd resubmission on this, please checkin)
3. firmware/fonts.h - doc change on .fnt file format, .fnt version
number incremented.
4. firmware/loadfont.c - fixes to load font properly, typedefs
removed.
5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before
issuing error, otherwise font may not exist.
6. tools/bdf2c - fixes for correct output when filename starts
with a number, as well as when no DEFAULT_CHAR in .bdf
file. (2nd resubmission on this, please checkin)
7. tools/writerbf.c - fixes for bugfixed fontfile format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
2002-09-16 03:18:49 +00:00
|
|
|
#define VERSION "RB11"
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
typedef unsigned short bitmap_t; /* bitmap image unit size*/
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* bitmap_t helper macros*/
|
|
|
|
#define BITMAP_WORDS(x) (((x)+15)/16) /* image size in words*/
|
|
|
|
#define BITMAP_BYTES(x) (BITMAP_WORDS(x)*sizeof(bitmap_t))
|
|
|
|
#define BITMAP_BITSPERIMAGE (sizeof(bitmap_t) * 8)
|
|
|
|
#define BITMAP_BITVALUE(n) ((bitmap_t) (((bitmap_t) 1) << (n)))
|
|
|
|
#define BITMAP_FIRSTBIT (BITMAP_BITVALUE(BITMAP_BITSPERIMAGE - 1))
|
|
|
|
#define BITMAP_TESTBIT(m) ((m) & BITMAP_FIRSTBIT)
|
|
|
|
#define BITMAP_SHIFTBIT(m) ((bitmap_t) ((m) << 1))
|
2002-09-12 13:33:59 +00:00
|
|
|
|
|
|
|
/* builtin C-based proportional/fixed font structure */
|
|
|
|
/* based on The Microwindows Project http://microwindows.org */
|
2002-09-20 08:07:51 +00:00
|
|
|
struct font {
|
2002-09-12 13:33:59 +00:00
|
|
|
char * name; /* font name*/
|
|
|
|
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*/
|
2002-09-20 08:07:51 +00:00
|
|
|
bitmap_t *bits; /* 16-bit right-padded bitmap data*/
|
2002-09-12 13:33:59 +00:00
|
|
|
unsigned long *offset; /* offsets into bitmap data*/
|
|
|
|
unsigned char *width; /* character widths or NULL if fixed*/
|
|
|
|
int defaultchar; /* default char (not glyph index)*/
|
2002-09-20 08:07:51 +00:00
|
|
|
long bits_size; /* # words of bitmap_t bits*/
|
2002-09-12 13:33:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* font routines*/
|
|
|
|
void font_init(void);
|
2002-09-20 08:07:51 +00:00
|
|
|
struct font* font_load(char *path);
|
|
|
|
struct font* font_get(int font);
|
2002-10-09 23:13:25 +00:00
|
|
|
void font_reset(void);
|
2002-09-12 13:33:59 +00:00
|
|
|
|
|
|
|
#else /* HAVE_LCD_BITMAP */
|
|
|
|
|
|
|
|
#define font_init()
|
2002-09-20 08:07:51 +00:00
|
|
|
#define font_load(x)
|
2002-09-12 13:33:59 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
* local variables:
|
|
|
|
* eval: (load-file "rockbox-mode.el")
|
Daniel,
The following patch makes loadable fonts actually work (finally!).
It took me quite a while, but I finally figured out why the sim
worked and the target didn't: the SH1 processor won't read
longwords from a shortword alignment... I had to rev the .fnt
file to version 1.1 (requires remaking *.fnt files) in order
to fix this. Please apply the following patch completely.
It's diffed against the latest CVS.
I've also attached rockbox-fonts-1.1.tar.gz which includes
known working *.fnt files, including a courB08 system.fnt,
for demonstration.
Now the real work can begin... Although the new
system.fnt will work fine, if you try going to a really
big font (try copying courB14.fnt to system.fnt), then
you will find that it comes up and works in tree mode,
but will crash the system when going into WPS
mode... I'm sure this is because of the low-level
lcd_bitmap not clipping properly when given a too-large
bitmap, which the characters become. I haven't yet
tried to debug the low-level driver. Of course, it all
works on the sim...
So the apps developers will now have to make sure that
all apps screen sizes may vary according to the loaded font.
The font height can be gotten through the lcd_getfontsize API.
Files patched in fonts-6.patch
1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin)
2. firmware/font.c - fixes and reformatting. Please check this in as is,
my vi editor requires more reformatting changes since I left tabs in the
file, these are removed now (2nd resubmission on this, please checkin)
3. firmware/fonts.h - doc change on .fnt file format, .fnt version
number incremented.
4. firmware/loadfont.c - fixes to load font properly, typedefs
removed.
5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before
issuing error, otherwise font may not exist.
6. tools/bdf2c - fixes for correct output when filename starts
with a number, as well as when no DEFAULT_CHAR in .bdf
file. (2nd resubmission on this, please checkin)
7. tools/writerbf.c - fixes for bugfixed fontfile format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
2002-09-16 03:18:49 +00:00
|
|
|
* vim: et sw=4 ts=8 sts=4 tw=78
|
2002-09-12 13:33:59 +00:00
|
|
|
* end:
|
|
|
|
*/
|