mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Fix bug with fonts containing missing glyphs before default glyph. Also, allow fonts with trailing space on BITMAP line.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9719 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ed44e19c3f
commit
359189efe3
1 changed files with 33 additions and 37 deletions
|
@ -503,7 +503,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strequal(buf, "BITMAP")) {
|
if (strequal(buf, "BITMAP") || strequal(buf, "BITMAP ")) {
|
||||||
bitmap_t *ch_bitmap = pf->bits + ofs;
|
bitmap_t *ch_bitmap = pf->bits + ofs;
|
||||||
int ch_words;
|
int ch_words;
|
||||||
|
|
||||||
|
@ -585,15 +585,12 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
||||||
/* set max width*/
|
/* set max width*/
|
||||||
pf->maxwidth = maxwidth;
|
pf->maxwidth = maxwidth;
|
||||||
|
|
||||||
/* change unused offset/width values to default char values*/
|
/* change unused width values to default char values*/
|
||||||
for (i=0; i<pf->size; ++i) {
|
for (i=0; i<pf->size; ++i) {
|
||||||
int defchar = pf->defaultchar - pf->firstchar;
|
int defchar = pf->defaultchar - pf->firstchar;
|
||||||
|
|
||||||
if (pf->offset[i] == (unsigned int)-1) {
|
if (pf->offset[i] == (unsigned int)-1)
|
||||||
pf->offset[i] = pf->offset[defchar];
|
|
||||||
pf->offrot[i] = pf->offrot[defchar];
|
|
||||||
pf->width[i] = pf->width[defchar];
|
pf->width[i] = pf->width[defchar];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* determine whether font doesn't require encode table*/
|
/* determine whether font doesn't require encode table*/
|
||||||
|
@ -767,7 +764,6 @@ int gen_c_source(struct font* pf, char *path)
|
||||||
{
|
{
|
||||||
FILE *ofp;
|
FILE *ofp;
|
||||||
int i, ofr = 0;
|
int i, ofr = 0;
|
||||||
int did_defaultchar = 0;
|
|
||||||
int did_syncmsg = 0;
|
int did_syncmsg = 0;
|
||||||
time_t t = time(0);
|
time_t t = time(0);
|
||||||
bitmap_t *ofs = pf->bits;
|
bitmap_t *ofs = pf->bits;
|
||||||
|
@ -823,22 +819,14 @@ int gen_c_source(struct font* pf, char *path)
|
||||||
int bitcount = 0;
|
int bitcount = 0;
|
||||||
int width = pf->width ? pf->width[i] : pf->maxwidth;
|
int width = pf->width ? pf->width[i] : pf->maxwidth;
|
||||||
int height = pf->height;
|
int height = pf->height;
|
||||||
bitmap_t *bits = pf->bits + (pf->offset? pf->offset[i]: (height * i));
|
bitmap_t *bits;
|
||||||
bitmap_t bitvalue;
|
bitmap_t bitvalue;
|
||||||
|
|
||||||
/*
|
/* Skip missing glyphs */
|
||||||
* Generate bitmap bits only if not this index isn't
|
if (pf->offset && (pf->offset[i] == (unsigned int)-1))
|
||||||
* the default character in encode map, or the default
|
continue;
|
||||||
* character hasn't been generated yet.
|
|
||||||
*/
|
bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i));
|
||||||
if (pf->offset &&
|
|
||||||
(pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) {
|
|
||||||
if (did_defaultchar) {
|
|
||||||
pf->offrot[i] = pf->offrot[pf->defaultchar-pf->firstchar];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
did_defaultchar = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d",
|
fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d",
|
||||||
i+pf->firstchar, i+pf->firstchar, width);
|
i+pf->firstchar, i+pf->firstchar, width);
|
||||||
|
@ -914,13 +902,18 @@ int gen_c_source(struct font* pf, char *path)
|
||||||
fprintf(ofp, "/* Character->glyph mapping. */\n"
|
fprintf(ofp, "/* Character->glyph mapping. */\n"
|
||||||
"static const unsigned short _sysfont_offset[] = {\n");
|
"static const unsigned short _sysfont_offset[] = {\n");
|
||||||
|
|
||||||
for (i=0; i<pf->size; ++i)
|
for (i=0; i<pf->size; ++i) {
|
||||||
|
if (pf->offset[i] == (unsigned int)-1) {
|
||||||
|
pf->offset[i] = pf->offset[pf->defaultchar - pf->firstchar];
|
||||||
|
pf->offrot[i] = pf->offrot[pf->defaultchar - pf->firstchar];
|
||||||
|
}
|
||||||
fprintf(ofp, " %ld,\t/* (0x%02x) */\n",
|
fprintf(ofp, " %ld,\t/* (0x%02x) */\n",
|
||||||
#ifdef ROTATE
|
#ifdef ROTATE
|
||||||
pf->offrot[i], i+pf->firstchar);
|
pf->offrot[i], i+pf->firstchar);
|
||||||
#else
|
#else
|
||||||
pf->offset[i], i+pf->firstchar);
|
pf->offset[i], i+pf->firstchar);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
fprintf(ofp, "};\n\n");
|
fprintf(ofp, "};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1016,7 +1009,6 @@ int gen_fnt_file(struct font* pf, char *path)
|
||||||
{
|
{
|
||||||
FILE *ofp;
|
FILE *ofp;
|
||||||
int i;
|
int i;
|
||||||
int did_defaultchar = 0;
|
|
||||||
#ifdef ROTATE
|
#ifdef ROTATE
|
||||||
int ofr = 0;
|
int ofr = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1053,19 +1045,16 @@ int gen_fnt_file(struct font* pf, char *path)
|
||||||
#ifdef ROTATE
|
#ifdef ROTATE
|
||||||
for (i=0; i<pf->size; ++i)
|
for (i=0; i<pf->size; ++i)
|
||||||
{
|
{
|
||||||
bitmap_t* bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i));
|
bitmap_t* bits;
|
||||||
int width = pf->width ? pf->width[i] : pf->maxwidth;
|
int width = pf->width ? pf->width[i] : pf->maxwidth;
|
||||||
int size;
|
int size;
|
||||||
unsigned char bytemap[256];
|
unsigned char bytemap[256];
|
||||||
|
|
||||||
if (pf->offset &&
|
/* Skip missing glyphs */
|
||||||
(pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) {
|
if (pf->offset && (pf->offset[i] == (unsigned int)-1))
|
||||||
if (did_defaultchar) {
|
continue;
|
||||||
pf->offrot[i] = pf->offrot[pf->defaultchar-pf->firstchar];
|
|
||||||
continue;
|
bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i));
|
||||||
}
|
|
||||||
did_defaultchar = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = rotleft(bytemap, bits, width, pf->height);
|
size = rotleft(bytemap, bits, width, pf->height);
|
||||||
writestr(ofp, (char *)bytemap, size);
|
writestr(ofp, (char *)bytemap, size);
|
||||||
|
@ -1092,6 +1081,9 @@ int gen_fnt_file(struct font* pf, char *path)
|
||||||
{
|
{
|
||||||
for (i=0; i<pf->size; ++i)
|
for (i=0; i<pf->size; ++i)
|
||||||
{
|
{
|
||||||
|
if (pf->offset[i] == (unsigned int)-1) {
|
||||||
|
pf->offrot[i] = pf->offrot[pf->defaultchar - pf->firstchar];
|
||||||
|
}
|
||||||
if ( pf->bits_size < 0xFFDB )
|
if ( pf->bits_size < 0xFFDB )
|
||||||
writeshort(ofp, pf->offrot[i]);
|
writeshort(ofp, pf->offrot[i]);
|
||||||
else
|
else
|
||||||
|
@ -1109,8 +1101,12 @@ int gen_fnt_file(struct font* pf, char *path)
|
||||||
writeshort(ofp, 0); /* pad to 32-bit boundary*/
|
writeshort(ofp, 0); /* pad to 32-bit boundary*/
|
||||||
|
|
||||||
if (pf->offset)
|
if (pf->offset)
|
||||||
for (i=0; i<pf->size; ++i)
|
for (i=0; i<pf->size; ++i) {
|
||||||
|
if (pf->offset[i] == (unsigned int)-1) {
|
||||||
|
pf->offset[i] = pf->offset[pf->defaultchar - pf->firstchar];
|
||||||
|
}
|
||||||
writeint(ofp, pf->offset[i]);
|
writeint(ofp, pf->offset[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (pf->width)
|
if (pf->width)
|
||||||
for (i=0; i<pf->size; ++i)
|
for (i=0; i<pf->size; ++i)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue