summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexander Levin <al.le@rockbox.org>2009-03-12 19:55:07 +0000
committerAlexander Levin <al.le@rockbox.org>2009-03-12 19:55:07 +0000
commitd59e310375adadc1e8d7a779a5000eac5eb1f734 (patch)
treed949a1a3ebaf914eb1b3e20ff45509d57233a5bd /tools
parent74aba34b5805b345a8f5f89657da4aeaaffcdb0c (diff)
downloadrockbox-d59e310375adadc1e8d7a779a5000eac5eb1f734.tar.gz
rockbox-d59e310375adadc1e8d7a779a5000eac5eb1f734.tar.bz2
rockbox-d59e310375adadc1e8d7a779a5000eac5eb1f734.zip
Provide information about how the font could be reduced without glyph clipping
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20307 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/convbdf.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c
index 6afa79ddc8..d530c6145f 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -57,6 +57,8 @@ struct font {
int nchars_declared; /* number of glyphs as declared in the header */
int ascent_declared; /* ascent as declared in the header */
int descent_declared; /* descent as declared in the header */
+ int max_char_ascent; /* max. char ascent (before adjusting) */
+ int max_char_descent; /* max. char descent (before adjusting) */
unsigned int* offrot; /* offsets into rotated bitmap data */
char* name; /* font name */
char* facename; /* facename of font */
@@ -503,6 +505,16 @@ struct font* bdf_read_font(char *path)
print_warning(VL_CLIP_FONT, "Generated font's height: %d\n", pf->height);
}
+ if (pf->ascent > pf->max_char_ascent) {
+ print_trace("Font's ascent could be reduced by %d to %d without clipping\n",
+ (pf->ascent - pf->max_char_ascent), pf->max_char_ascent);
+ }
+ if (pf->descent > pf->max_char_descent) {
+ print_trace("Font's descent could be reduced by %d to %d without clipping\n",
+ (pf->descent - pf->max_char_descent), pf->max_char_descent);
+ }
+
+
/* Alocate memory */
pf->bits_size = pf->size * BITMAP_WORDS(pf->maxwidth) * pf->height;
pf->bits = (bitmap_t *)malloc(pf->bits_size * sizeof(bitmap_t));
@@ -935,7 +947,7 @@ void bdf_correct_bbx(int *width, int *bbx) {
int bdf_analyze_font(FILE *fp, struct font* pf) {
char buf[256];
int encoding;
- int width, bbw, bbh, bbx, bby, overflow;
+ int width, bbw, bbh, bbx, bby, ascent, overflow;
int read_enc = 0, read_width = 0, read_bbx = 0, read_endchar = 1;
int ignore_char = 0;
@@ -944,6 +956,7 @@ int bdf_analyze_font(FILE *fp, struct font* pf) {
pf->maxwidth = 0;
pf->nchars = 0;
+ pf->max_char_ascent = pf->max_char_descent = 0;
pf->max_over_ascent = pf->max_over_descent = 0;
for (;;) {
@@ -983,14 +996,16 @@ int bdf_analyze_font(FILE *fp, struct font* pf) {
if (width > pf->maxwidth) {
pf->maxwidth = width;
}
- overflow = bby + bbh - pf->ascent;
- if (overflow > pf->max_over_ascent) {
- pf->max_over_ascent = overflow;
- }
- overflow = -bby - pf->descent;
- if (overflow > pf->max_over_descent) {
- pf->max_over_descent = overflow;
- }
+
+ ascent = bby + bbh;
+ pf->max_char_ascent = MAX(pf->max_char_ascent, ascent);
+ overflow = ascent - pf->ascent;
+ pf->max_over_ascent = MAX(pf->max_over_ascent, overflow);
+
+ ascent = -bby;
+ pf->max_char_descent = MAX(pf->max_char_descent, ascent);
+ overflow = ascent - pf->descent;
+ pf->max_over_descent = MAX(pf->max_over_descent, overflow);
}
pf->nchars++;
read_endchar = 1;