diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-05-11 00:01:02 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-05-11 00:01:02 +0000 |
commit | e90acbb3dd052ae075bac3e3aa8c9a7ecbf889d1 (patch) | |
tree | 9bc257098f664dcc3aee4b7828354bab36838acc /src/intmetrics.c | |
parent | dda72e9bf55f2d47d24a9df63d30ea3bcb92f1e3 (diff) | |
download | ttf2f-e90acbb3dd052ae075bac3e3aa8c9a7ecbf889d1.tar.gz ttf2f-e90acbb3dd052ae075bac3e3aa8c9a7ecbf889d1.tar.bz2 |
Write out font metrics so that the first 256 glyphs match Acorn Latin 1.
Don't use this version -- it will produce inconsistent font data (outlines and encoding export needs the same thing doing to it)
svn path=/trunk/tools/ttf2f/; revision=7460
Diffstat (limited to 'src/intmetrics.c')
-rw-r--r-- | src/intmetrics.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/intmetrics.c b/src/intmetrics.c index 6b9c297..3c99696 100644 --- a/src/intmetrics.c +++ b/src/intmetrics.c @@ -76,37 +76,42 @@ ttf2f_result intmetrics_write(const char *savein, const char *name, struct intmetrics_header header; short *xwidthtab = NULL; unsigned int xwidthtab_size = 0; + int xwidthtab_idx = sizeof(ctx->latin1tab); short mapsize; size_t i, name_len; - const struct glyph *g; + struct glyph *g; char out[1024]; FILE *output; - /* allow for chunk 0 */ - xwidthtab = calloc(33, sizeof(short)); + /* Total number of slots is the number of glyphs plus any spare + * required for the latin1 table */ + xwidthtab_size = ctx->nglyphs + sizeof(ctx->latin1tab) - ctx->nlatin1; + + xwidthtab = calloc(xwidthtab_size, sizeof(short)); if (xwidthtab == NULL) return TTF2F_RESULT_NOMEM; - xwidthtab_size = 32; + /* fill latin1 subset first */ + for (i = 0; i != sizeof(ctx->latin1tab); i++) { + g = ctx->latin1tab[i]; - /* create xwidthtab - char code is now the index */ - for (i = 0; i != ctx->nglyphs; i++) { - short *temp; + xwidthtab[i] = g != NULL ? g->width : 0; + if (g != NULL) + g->done_intmetrics = 1; + } + + /* then the rest, skipping those we've already written */ + for (i = 0; i != ctx->nglyphs; i++) { g = &ctx->glyphs[i]; callback((i * 100) / ctx->nglyphs); ttf2f_poll(1); - xwidthtab_size++; - /* +32 to skip chunk 0 */ - xwidthtab[i + 32] = g->width; - temp = realloc(xwidthtab, (xwidthtab_size + 1) * sizeof(short)); - if (temp == NULL) { - free(xwidthtab); - return TTF2F_RESULT_NOMEM; + if (g->done_intmetrics == 0) { + xwidthtab[xwidthtab_idx++] = g->width; + g->done_intmetrics = 1; } - xwidthtab = temp; } /* fill in header */ @@ -129,7 +134,7 @@ ttf2f_result intmetrics_write(const char *savein, const char *name, return TTF2F_RESULT_OPEN; } - if (fwrite((void*)&header, sizeof(struct intmetrics_header), + if (fwrite((void*) &header, sizeof(struct intmetrics_header), 1, output) != 1) goto error_write; if (fputc(mapsize & 0xFF, output) == EOF) goto error_write; |