From c42e6e6d1d04ef45cfb7b30a5363cc3003eb268c Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 11 May 2009 00:19:13 +0000 Subject: Make encoding file output emit latin1 table first svn path=/trunk/tools/ttf2f/; revision=7462 --- src/encoding.c | 72 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/src/encoding.c b/src/encoding.c index ae4b43c..b331355 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -6,6 +6,9 @@ #include "glyph.h" #include "utils.h" +static void encoding_write_glyph(int index, struct glyph *glyph, + encoding_type type, FILE *fp); + /** * Write font encoding file * @@ -31,39 +34,32 @@ ttf2f_result encoding_write(const char *savein, const char *name, fprintf(output, "%% %sEncoding 1.00\n", name); fprintf(output, "%% Encoding file for font '%s'\n\n", name); - if (type == ENCODING_TYPE_NORMAL) { - for (i = 0; i != 32; i++) { - fprintf(output, "/.notdef\n"); + /* Write latin1 first */ + for (i = 0; i != sizeof(ctx->latin1tab); i++) { + if (ctx->latin1tab[i] == NULL) { + if (type == ENCODING_TYPE_NORMAL) { + fprintf(output, "/.notdef\n"); + } + } else { + encoding_write_glyph(i, ctx->latin1tab[i], + type, output); + + ctx->latin1tab[i]->done_encoding = 1; } } + /* Then the rest, skipping the ones we've already written */ for (i = 0; i != ctx->nglyphs; i++) { g = &ctx->glyphs[i]; callback(i * 100 / ctx->nglyphs); ttf2f_poll(1); - if (type == ENCODING_TYPE_SPARSE) { - if (g->name != 0) { - /* .notdef is implicit */ - if (strcmp(g->name, ".notdef") == 0) - continue; - fprintf(output, "%4.4zX;%s;COMMENT\n", i+32, - g->name); - } else if (g->code != (unsigned int) -1) { - fprintf(output, "%4.4zX;uni%04X;COMMENT\n", - i+32, g->code); - } else { - fprintf(output, "# Skipping %4.4zX\n", i+32); - } - } else { - if (g->name != 0) { - fprintf(output, "/%s\n", g->name); - } else if (g->code != (unsigned int) -1) { - fprintf(output, "/uni%4.4X\n", g->code); - } else { - fprintf(output, "/.notdef\n"); - } + if (g->done_encoding == 0) { + encoding_write_glyph(i + sizeof(ctx->latin1tab), + g, type, output); + + g->done_encoding = 1; } } @@ -72,3 +68,31 @@ ttf2f_result encoding_write(const char *savein, const char *name, return TTF2F_RESULT_OK; } +void encoding_write_glyph(int index, struct glyph *glyph, + encoding_type type, FILE *fp) +{ + if (type == ENCODING_TYPE_SPARSE) { + if (glyph->name != 0) { + /* .notdef is implicit */ + if (strcmp(glyph->name, ".notdef") != 0) { + fprintf(fp, "%4.4X;%s;COMMENT\n", index, + glyph->name); + } + } else if (glyph->code != (unsigned int) -1) { + fprintf(fp, "%4.4X;uni%04X;COMMENT\n", index, + glyph->code); + } else { + fprintf(fp, "# Skipping %4.4X\n", index); + } + } else { + if (glyph->name != 0) { + fprintf(fp, "/%s\n", glyph->name); + } else if (glyph->code != (unsigned int) -1) { + fprintf(fp, "/uni%4.4X\n", glyph->code); + } else { + fprintf(fp, "/.notdef\n"); + } + } +} + + -- cgit v1.2.3