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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
/*
|
|
|
|
* Rockbox startup font initialization
|
|
|
|
* This file specifies which fonts get compiled-in and
|
|
|
|
* loaded at startup, as well as their mapping into
|
|
|
|
* the FONT_SYSFIXED, FONT_UI and FONT_MP3 ids.
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "font.h"
|
2002-09-20 08:07:51 +00:00
|
|
|
#include "file.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "panic.h"
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
#ifndef O_BINARY
|
|
|
|
#define O_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* compiled-in font */
|
|
|
|
extern struct font sysfont;
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* structure filled in by font_load */
|
|
|
|
static struct font font_ui;
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* system font table, in order of FONT_xxx definition */
|
|
|
|
static struct font* sysfonts[MAXFONTS] = { &sysfont, &font_ui };
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* static buffer allocation structures */
|
|
|
|
static unsigned char mbuf[MAX_FONT_SIZE];
|
|
|
|
static unsigned char *freeptr = mbuf;
|
|
|
|
static unsigned char *fileptr;
|
|
|
|
static unsigned char *eofptr;
|
2002-09-13 06:37:49 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
static void rotate_font_bits(struct font* pf);
|
|
|
|
static void rotleft(unsigned char *dst,
|
|
|
|
bitmap_t *src,
|
|
|
|
unsigned int width,
|
|
|
|
unsigned int height);
|
|
|
|
|
|
|
|
void font_init(void)
|
2002-09-12 13:33:59 +00:00
|
|
|
{
|
2002-09-20 08:07:51 +00:00
|
|
|
rotate_font_bits(&sysfont);
|
|
|
|
memset(&font_ui, 0, sizeof(struct font));
|
|
|
|
}
|
2002-09-13 06:37:49 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
static int readshort(unsigned short *sp)
|
|
|
|
{
|
|
|
|
unsigned short s;
|
|
|
|
|
|
|
|
s = *fileptr++ & 0xff;
|
|
|
|
*sp = (*fileptr++ << 8) | s;
|
|
|
|
return (fileptr <= eofptr);
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
static int readlong(unsigned long *lp)
|
2002-09-12 13:33:59 +00:00
|
|
|
{
|
2002-09-20 08:07:51 +00:00
|
|
|
unsigned long l;
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
l = *fileptr++ & 0xff;
|
|
|
|
l |= *fileptr++ << 8;
|
|
|
|
l |= *fileptr++ << 16;
|
|
|
|
*lp = (*fileptr++ << 24) | l;
|
|
|
|
return (fileptr <= eofptr);
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* read count bytes*/
|
|
|
|
static int readstr(char *buf, int count)
|
2002-09-12 13:33:59 +00:00
|
|
|
{
|
2002-09-20 08:07:51 +00:00
|
|
|
int n = count;
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
while (--n >= 0)
|
|
|
|
*buf++ = *fileptr++;
|
|
|
|
return (fileptr <= eofptr)? count: 0;
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* read totlen bytes, return NUL terminated string*/
|
|
|
|
/* may write 1 past buf[totlen]; removes blank pad*/
|
|
|
|
static int readstrpad(char *buf, int totlen)
|
2002-09-12 13:33:59 +00:00
|
|
|
{
|
2002-09-20 08:07:51 +00:00
|
|
|
char *p = buf;
|
|
|
|
int n = totlen;
|
|
|
|
|
|
|
|
while (--n >= 0)
|
|
|
|
*p++ = *fileptr++;
|
|
|
|
if (fileptr > eofptr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
p = &buf[totlen];
|
|
|
|
*p-- = 0;
|
|
|
|
while (*p == ' ' && p >= buf)
|
|
|
|
*p-- = '\0';
|
|
|
|
return totlen;
|
|
|
|
}
|
|
|
|
|
2002-10-09 23:13:25 +00:00
|
|
|
void font_reset(void)
|
|
|
|
{
|
|
|
|
memset(&font_ui, 0, sizeof(struct font));
|
|
|
|
}
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* read and load font into incore font structure*/
|
|
|
|
struct font* font_load(char *path)
|
|
|
|
{
|
|
|
|
int fd, filesize;
|
|
|
|
unsigned short maxwidth, height, ascent, pad;
|
|
|
|
unsigned long firstchar, defaultchar, size;
|
|
|
|
unsigned long i, nbits, noffset, nwidth;
|
|
|
|
char version[4+1];
|
|
|
|
char copyright[256+1];
|
|
|
|
struct font* pf = &font_ui;
|
|
|
|
|
|
|
|
/* open and read entire font file*/
|
|
|
|
fd = open(path, O_RDONLY|O_BINARY);
|
|
|
|
if (fd < 0) {
|
|
|
|
DEBUGF("Can't open font: %s\n", path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-10-09 23:13:25 +00:00
|
|
|
font_reset();
|
2002-10-08 15:42:40 +00:00
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* currently, font loading replaces earlier font allocation*/
|
|
|
|
freeptr = (unsigned char *)(((int)mbuf + 3) & ~3);
|
|
|
|
|
|
|
|
fileptr = freeptr;
|
|
|
|
filesize = read(fd, fileptr, MAX_FONT_SIZE);
|
|
|
|
eofptr = fileptr + filesize;
|
|
|
|
|
|
|
|
/* no need for multiple font loads currently*/
|
|
|
|
/*freeptr += filesize;*/
|
|
|
|
/*freeptr = (unsigned char *)(freeptr + 3) & ~3;*/ /* pad freeptr*/
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
if (filesize == MAX_FONT_SIZE) {
|
|
|
|
DEBUGF("Font %s too large: %d\n", path, filesize);
|
|
|
|
return NULL;
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
/* read magic and version #*/
|
|
|
|
memset(version, 0, sizeof(version));
|
|
|
|
if (readstr(version, 4) != 4)
|
|
|
|
return NULL;
|
|
|
|
if (strcmp(version, VERSION) != 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* internal font name*/
|
|
|
|
pf->name = fileptr;
|
|
|
|
if (readstrpad(pf->name, 64) != 64)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* copyright, not currently stored*/
|
|
|
|
if (readstrpad(copyright, 256) != 256)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* font info*/
|
|
|
|
if (!readshort(&maxwidth))
|
|
|
|
return NULL;
|
|
|
|
pf->maxwidth = maxwidth;
|
|
|
|
if (!readshort(&height))
|
|
|
|
return NULL;
|
|
|
|
pf->height = height;
|
|
|
|
if (!readshort(&ascent))
|
|
|
|
return NULL;
|
|
|
|
pf->ascent = ascent;
|
|
|
|
if (!readshort(&pad))
|
|
|
|
return NULL;
|
|
|
|
if (!readlong(&firstchar))
|
|
|
|
return NULL;
|
|
|
|
pf->firstchar = firstchar;
|
|
|
|
if (!readlong(&defaultchar))
|
|
|
|
return NULL;
|
|
|
|
pf->defaultchar = defaultchar;
|
|
|
|
if (!readlong(&size))
|
|
|
|
return NULL;
|
|
|
|
pf->size = size;
|
|
|
|
|
|
|
|
/* get variable font data sizes*/
|
|
|
|
/* # words of bitmap_t*/
|
|
|
|
if (!readlong(&nbits))
|
|
|
|
return NULL;
|
|
|
|
pf->bits_size = nbits;
|
|
|
|
|
|
|
|
/* # longs of offset*/
|
|
|
|
if (!readlong(&noffset))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* # bytes of width*/
|
|
|
|
if (!readlong(&nwidth))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* variable font data*/
|
|
|
|
pf->bits = (bitmap_t *)fileptr;
|
|
|
|
for (i=0; i<nbits; ++i)
|
|
|
|
if (!readshort(&pf->bits[i]))
|
|
|
|
return NULL;
|
|
|
|
/* pad to longword boundary*/
|
|
|
|
fileptr = (unsigned char *)(((int)fileptr + 3) & ~3);
|
|
|
|
|
|
|
|
if (noffset) {
|
|
|
|
pf->offset = (unsigned long *)fileptr;
|
|
|
|
for (i=0; i<noffset; ++i)
|
|
|
|
if (!readlong(&pf->offset[i]))
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pf->offset = NULL;
|
|
|
|
|
|
|
|
if (nwidth) {
|
|
|
|
pf->width = (unsigned char *)fileptr;
|
|
|
|
fileptr += nwidth*sizeof(unsigned char);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pf->width = NULL;
|
|
|
|
|
|
|
|
if (fileptr > eofptr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* one-time rotate font bits to rockbox format*/
|
|
|
|
rotate_font_bits(pf);
|
|
|
|
|
|
|
|
return pf; /* success!*/
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2002-09-13 06:37:49 +00:00
|
|
|
/*
|
2002-09-20 08:07:51 +00:00
|
|
|
* Return a pointer to an incore font structure.
|
|
|
|
* If the requested font isn't loaded/compiled-in,
|
|
|
|
* decrement the font number and try again.
|
2002-09-13 06:37:49 +00:00
|
|
|
*/
|
2002-09-20 08:07:51 +00:00
|
|
|
struct font* font_get(int font)
|
2002-09-13 06:37:49 +00:00
|
|
|
{
|
2002-09-20 08:07:51 +00:00
|
|
|
struct font* pf;
|
|
|
|
|
|
|
|
if (font >= MAXFONTS)
|
|
|
|
font = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
pf = sysfonts[font];
|
|
|
|
if (pf && pf->height)
|
|
|
|
return pf;
|
|
|
|
if (--font < 0)
|
|
|
|
panicf("No font!");
|
2002-09-13 06:37:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert font bitmap data inplace to rockbox format*/
|
2002-09-20 08:07:51 +00:00
|
|
|
static void rotate_font_bits(struct font* pf)
|
2002-09-13 06:37:49 +00:00
|
|
|
{
|
|
|
|
int i;
|
2002-09-20 08:07:51 +00:00
|
|
|
unsigned long defaultchar = pf->defaultchar - pf->firstchar;
|
|
|
|
bool did_defaultchar = false;
|
2002-09-13 06:37:49 +00:00
|
|
|
unsigned char buf[256];
|
|
|
|
|
|
|
|
for (i=0; i<pf->size; ++i) {
|
2002-09-20 08:07:51 +00:00
|
|
|
bitmap_t *bits = pf->bits +
|
|
|
|
(pf->offset ? pf->offset[i] : (pf->height * i));
|
2002-09-13 06:37:49 +00:00
|
|
|
int width = pf->width? pf->width[i]: pf->maxwidth;
|
2002-09-20 08:07:51 +00:00
|
|
|
int src_bytes = BITMAP_BYTES(width) * pf->height;
|
2002-09-13 06:37:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Due to the way the offset map works,
|
|
|
|
* non-mapped characters are mapped to the default
|
|
|
|
* character, and shouldn't be rotated twice.
|
|
|
|
*/
|
2002-09-20 08:07:51 +00:00
|
|
|
|
|
|
|
if (pf->offset && pf->offset[i] == defaultchar) {
|
2002-09-13 06:37:49 +00:00
|
|
|
if (did_defaultchar)
|
|
|
|
continue;
|
2002-09-20 08:07:51 +00:00
|
|
|
did_defaultchar = true;
|
2002-09-13 06:37:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rotate left for lcd_bitmap function input*/
|
|
|
|
rotleft(buf, bits, width, pf->height);
|
|
|
|
|
|
|
|
/* copy back into original location*/
|
|
|
|
memcpy(bits, buf, src_bytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-12 13:33:59 +00:00
|
|
|
/*
|
2002-09-20 08:07:51 +00:00
|
|
|
* Take an bitmap_t bitmap and convert to Rockbox format.
|
2002-09-12 13:33:59 +00:00
|
|
|
* Used for converting font glyphs for the time being.
|
|
|
|
* Can use for standard X11 and Win32 images as well.
|
|
|
|
*
|
|
|
|
* Doing it this way keeps fonts in standard formats,
|
|
|
|
* as well as keeping Rockbox hw bitmap format.
|
|
|
|
*/
|
2002-09-20 08:07:51 +00:00
|
|
|
static void rotleft(unsigned char *dst, bitmap_t *src, unsigned int width,
|
|
|
|
unsigned int height)
|
2002-09-12 13:33:59 +00:00
|
|
|
{
|
|
|
|
unsigned int i,j;
|
|
|
|
unsigned int dst_col = 0; /* destination column*/
|
|
|
|
unsigned int dst_shift = 0; /* destination shift amount*/
|
|
|
|
unsigned int dst_linelen; /* # bytes per output row*/
|
|
|
|
unsigned int src_words; /* # words of input image*/
|
|
|
|
|
|
|
|
/* calc bytes per output row*/
|
|
|
|
dst_linelen = (height-1)/8+1;
|
|
|
|
|
|
|
|
/* calc words of input image*/
|
2002-09-20 08:07:51 +00:00
|
|
|
src_words = BITMAP_WORDS(width) * height;
|
2002-09-12 13:33:59 +00:00
|
|
|
|
|
|
|
/* clear background*/
|
2002-09-13 06:37:49 +00:00
|
|
|
memset(dst, 0, dst_linelen*width);
|
2002-09-12 13:33:59 +00:00
|
|
|
|
|
|
|
for (i=0; i < src_words; i++) {
|
2002-09-20 08:07:51 +00:00
|
|
|
bitmap_t srcmap; /* current src input bit*/
|
|
|
|
bitmap_t dstmap; /* current dst output bit*/
|
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
|
|
|
/* calc src input bit*/
|
2002-09-20 08:07:51 +00:00
|
|
|
srcmap = 1 << (sizeof(bitmap_t)*8-1);
|
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
|
|
|
/* calc dst output bit*/
|
2002-09-12 13:33:59 +00:00
|
|
|
if (i>0 && (i%8==0)) {
|
|
|
|
++dst_col;
|
|
|
|
dst_shift = 0;
|
|
|
|
}
|
|
|
|
dstmap = 1 << dst_shift++;
|
|
|
|
|
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
|
|
|
/* for each input column...*/
|
2002-09-12 13:33:59 +00:00
|
|
|
for(j=0; j < width; j++) {
|
|
|
|
|
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
|
|
|
/* calc input bitmask*/
|
2002-09-20 08:07:51 +00:00
|
|
|
bitmap_t bit = srcmap >> j;
|
2002-09-12 13:33:59 +00:00
|
|
|
if (bit==0) {
|
2002-09-20 08:07:51 +00:00
|
|
|
srcmap = 1 << (sizeof(bitmap_t)*8-1);
|
2002-09-12 13:33:59 +00:00
|
|
|
bit = srcmap >> (j % 16);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* if set in input, set in rotated output*/
|
|
|
|
if (bit & src[i]) {
|
|
|
|
/* input column j becomes output row*/
|
2002-09-12 13:33:59 +00:00
|
|
|
dst[j*dst_linelen + dst_col] |= dstmap;
|
|
|
|
}
|
2002-09-13 06:37:49 +00:00
|
|
|
/*debugf((bit & src[i])? "*": ".");*/
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
2002-09-13 06:37:49 +00:00
|
|
|
/*debugf("\n");*/
|
2002-09-12 13:33:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
|
|
|
|
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
* 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:
|
|
|
|
*/
|