summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexander Levin <al.le@rockbox.org>2009-04-29 21:51:04 +0000
committerAlexander Levin <al.le@rockbox.org>2009-04-29 21:51:04 +0000
commitecd4394f624b9f10b091bc90a63fd80653f85fad (patch)
treea3e6cb3507dec55492c6406b8d7e9f6b30444b35 /tools
parent19c258847109d04d65eaddc07532c250ab7df5dc (diff)
downloadrockbox-ecd4394f624b9f10b091bc90a63fd80653f85fad.tar.gz
rockbox-ecd4394f624b9f10b091bc90a63fd80653f85fad.tar.bz2
rockbox-ecd4394f624b9f10b091bc90a63fd80653f85fad.zip
Allow to specify DWIDTH at font level making DWIDTH at char level optional (FS#10176 by Yoshihisa Uchida with minor modifications by me)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20828 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/convbdf.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c
index 9b181a4f82..9f6152ebc1 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -72,6 +72,9 @@ struct font {
/* The number of clipped ascents/descents/total */
int num_clipped_ascent, num_clipped_descent, num_clipped;
+
+ /* default width in pixels (can be overwritten at char level) */
+ int default_width;
};
/* END font.h*/
@@ -567,11 +570,13 @@ int bdf_read_header(FILE *fp, struct font* pf)
char buf[256];
char facename[256];
char copyright[256];
+ int is_header = 1;
/* set certain values to errors for later error checking */
pf->defaultchar = -1;
pf->ascent = -1;
pf->descent = -1;
+ pf->default_width = -1;
for (;;) {
if (!bdf_getline(fp, buf, sizeof(buf))) {
@@ -631,6 +636,19 @@ int bdf_read_header(FILE *fp, struct font* pf)
}
continue;
}
+ if (isprefix(buf, "ENDPROPERTIES") || isprefix(buf, "STARTCHAR")) {
+ is_header = 0;
+ continue;
+ }
+
+ /* for BDF version 2.2 */
+ if (is_header && isprefix(buf, "DWIDTH ")) {
+ if (sscanf(buf, "DWIDTH %d", &pf->default_width) != 1) {
+ print_error("bad 'DWIDTH' at font level\n");
+ return 0;
+ }
+ continue;
+ }
/*
* Reading ENCODING is necessary to get firstchar/lastchar
@@ -751,6 +769,9 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
if (encoding < 0)
continue;
+ if (width < 0 && pf->default_width > 0)
+ width = pf->default_width;
+
/* set bits offset in encode map*/
if (pf->offset[encoding-pf->firstchar] != -1) {
print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n",
@@ -992,6 +1013,11 @@ int bdf_analyze_font(FILE *fp, struct font* pf) {
}
ignore_char = (encoding < start_char || encoding > limit_char);
if (!ignore_char) {
+ if (!read_width && pf->default_width > 0)
+ {
+ width = pf->default_width;
+ read_width = 1;
+ }
if (!read_width || !read_bbx) {
print_error("WIDTH or BBX is not specified for character %d\n",
encoding);