Provide better stats (print the total number of glyphs as well)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20210 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Alexander Levin 2009-03-05 23:06:00 +00:00
parent cf25649597
commit 2bbfd6f4ff

View file

@ -40,14 +40,15 @@ struct font {
int height; /* height in pixels*/ int height; /* height in pixels*/
int ascent; /* ascent (baseline) height*/ int ascent; /* ascent (baseline) height*/
int firstchar; /* first character in bitmap*/ int firstchar; /* first character in bitmap*/
int size; /* font size in glyphs*/ int size; /* font size in glyphs ('holes' included) */
bitmap_t* bits; /* 16-bit right-padded bitmap data*/ bitmap_t* bits; /* 16-bit right-padded bitmap data*/
unsigned int* offset; /* offsets into bitmap data*/ unsigned int* offset; /* offsets into bitmap data*/
unsigned char* width; /* character widths or NULL if fixed*/ unsigned char* width; /* character widths or NULL if fixed*/
int defaultchar; /* default char (not glyph index)*/ int defaultchar; /* default char (not glyph index)*/
int bits_size; /* # words of bitmap_t bits*/ int bits_size; /* # words of bitmap_t bits*/
/* unused by runtime system, read in by convbdf*/ /* unused by runtime system, read in by convbdf */
unsigned int nchars; /* number of different glyphs */
unsigned int* offrot; /* offsets into rotated bitmap data*/ unsigned int* offrot; /* offsets into rotated bitmap data*/
char * name; /* font name*/ char * name; /* font name*/
char * facename; /* facename of font*/ char * facename; /* facename of font*/
@ -328,9 +329,10 @@ struct font* bdf_read_font(char *path)
} }
if (pf->num_clipped > 0) { if (pf->num_clipped > 0) {
fprintf(stderr, "Warning: %d characters were clipped " fprintf(stderr, "Warning: %d characters out of %u were clipped "
"(%d at ascent, %d at descent)\n", "(%d at ascent, %d at descent)\n",
pf->num_clipped, pf->num_clipped_ascent, pf->num_clipped_descent); pf->num_clipped, pf->nchars,
pf->num_clipped_ascent, pf->num_clipped_descent);
fprintf(stderr, " max overflows: ascent: %d, descent: %d\n", fprintf(stderr, " max overflows: ascent: %d, descent: %d\n",
pf->max_over_ascent, pf->max_over_descent); pf->max_over_ascent, pf->max_over_descent);
} }
@ -348,7 +350,7 @@ struct font* bdf_read_font(char *path)
int bdf_read_header(FILE *fp, struct font* pf) int bdf_read_header(FILE *fp, struct font* pf)
{ {
int encoding; int encoding;
int nchars, maxwidth; int maxwidth;
int firstchar = 65535; int firstchar = 65535;
int lastchar = -1; int lastchar = -1;
char buf[256]; char buf[256];
@ -410,7 +412,7 @@ int bdf_read_header(FILE *fp, struct font* pf)
continue; continue;
} }
if (isprefix(buf, "CHARS ")) { if (isprefix(buf, "CHARS ")) {
if (sscanf(buf, "CHARS %d", &nchars) != 1) { if (sscanf(buf, "CHARS %u", &pf->nchars) != 1) {
fprintf(stderr, "Error: bad 'CHARS'\n"); fprintf(stderr, "Error: bad 'CHARS'\n");
return 0; return 0;
} }
@ -465,7 +467,7 @@ int bdf_read_header(FILE *fp, struct font* pf)
maxwidth = pf->fbbw; maxwidth = pf->fbbw;
/* initially use font maxwidth * height for bits allocation*/ /* initially use font maxwidth * height for bits allocation*/
pf->bits_size = nchars * BITMAP_WORDS(maxwidth) * pf->height; pf->bits_size = pf->nchars * BITMAP_WORDS(maxwidth) * pf->height;
/* allocate bits, offset, and width arrays*/ /* allocate bits, offset, and width arrays*/
pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t) + EXTRA); pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t) + EXTRA);