patch #1267220 by Frank - phaedrus961

Currently convbdf will sort the bits order in the order of the encoding when
creating the .c or .fnt file, but it doesn't update the offsets. This patch
makes sure the offsets are updated along with the bits, so that fonts with out
of order glyphs display properly.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7392 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2005-08-23 21:38:26 +00:00
parent 984712f291
commit 2d2b1e7cd5

View file

@ -767,7 +767,7 @@ int rotleft(unsigned char *dst, bitmap_t *src, unsigned int width,
int gen_c_source(struct font* pf, char *path) int gen_c_source(struct font* pf, char *path)
{ {
FILE *ofp; FILE *ofp;
int i; int i, ofr = 0;
int did_defaultchar = 0; int did_defaultchar = 0;
int did_syncmsg = 0; int did_syncmsg = 0;
time_t t = time(0); time_t t = time(0);
@ -834,8 +834,10 @@ int gen_c_source(struct font* pf, char *path)
*/ */
if (pf->offset && if (pf->offset &&
(pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) { (pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) {
if (did_defaultchar) if (did_defaultchar) {
pf->offrot[i] = pf->offrot[pf->defaultchar-pf->firstchar];
continue; continue;
}
did_defaultchar = 1; did_defaultchar = 1;
} }
@ -881,7 +883,7 @@ int gen_c_source(struct font* pf, char *path)
unsigned char bytemap[256]; unsigned char bytemap[256];
int y8, ix=0; int y8, ix=0;
rotleft(bytemap, bits, width, pf->height); int size = rotleft(bytemap, bits, width, pf->height);
for (y8=0; y8<pf->height; y8+=8) /* column rows */ for (y8=0; y8<pf->height; y8+=8) /* column rows */
{ {
for (x=0; x<width; x++) { for (x=0; x<width; x++) {
@ -890,6 +892,11 @@ int gen_c_source(struct font* pf, char *path)
} }
fprintf(ofp, "\n"); fprintf(ofp, "\n");
} }
/* update offrot since bits are now in sorted order */
pf->offrot[i] = ofr;
ofr += size;
} }
#else #else
for (x=BITMAP_WORDS(width)*pf->height; x>0; --x) { for (x=BITMAP_WORDS(width)*pf->height; x>0; --x) {
@ -1040,6 +1047,7 @@ int gen_fnt_file(struct font* pf, char *path)
writelong(ofp, pf->width? pf->size: 0); /* # bytes of width*/ writelong(ofp, pf->width? pf->size: 0); /* # bytes of width*/
/* variable font data*/ /* variable font data*/
#ifdef ROTATE #ifdef ROTATE
int ofr = 0;
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 = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i));
@ -1049,13 +1057,19 @@ int gen_fnt_file(struct font* pf, char *path)
if (pf->offset && if (pf->offset &&
(pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) { (pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) {
if (did_defaultchar) if (did_defaultchar) {
pf->offrot[i] = pf->offrot[pf->defaultchar-pf->firstchar];
continue; continue;
}
did_defaultchar = 1; did_defaultchar = 1;
} }
size = rotleft(bytemap, bits, width, pf->height); size = rotleft(bytemap, bits, width, pf->height);
writestr(ofp, bytemap, size); writestr(ofp, (char *)bytemap, size);
/* update offrot since bits are now in sorted order */
pf->offrot[i] = ofr;
ofr += size;
} }
if (ftell(ofp) & 1) if (ftell(ofp) & 1)