From 670fe1b085fde8355b6d1a70b143eab60e34b1b6 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 13 Apr 2017 19:13:59 +0100 Subject: Use splay trees for loading/merging cmaps. This allows for overlaps, merges adjacent (mergeable) ranges and gets us properly searchable results. This causes 1 diff in the test suites (Bug694353.pdf), which is due to the fallback font not having a hypen present at UCS 0x2010. --- scripts/cmapdump.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'scripts/cmapdump.c') diff --git a/scripts/cmapdump.c b/scripts/cmapdump.c index eb84cb4c..e8ed5742 100644 --- a/scripts/cmapdump.c +++ b/scripts/cmapdump.c @@ -51,7 +51,7 @@ main(int argc, char **argv) FILE *fo; char name[256]; char *realname; - int i, k, m; + int i, k; fz_context *ctx; if (argc < 3) @@ -141,10 +141,19 @@ main(int argc, char **argv) fprintf(fo, "static const pdf_mrange cmap_%s_mranges[] = {", name); for (k = 0; k < cmap->mlen; k++) { - fprintf(fo, "\n{%uu,%uu,{", cmap->mranges[k].low, cmap->mranges[k].len); - for (m = 0; m < PDF_MRANGE_CAP; ++m) - fprintf(fo, "%uu,", cmap->mranges[k].out[m]); - fprintf(fo, "}},"); + fprintf(fo, "\n{%uu,%uu},", cmap->mranges[k].low, cmap->mranges[k].out); + } + fprintf(fo, "\n};\n\n"); + } + + if (cmap->dlen > 0) + { + fprintf(fo, "static const int cmap_%s_dict[] = {", name); + for (k = 0; k < cmap->dlen; k++) + { + if (k % 4 == 0) + fprintf(fo, "\n"); + fprintf(fo, "%uu,", cmap->dict[k]); } fprintf(fo, "\n};\n\n"); } @@ -177,6 +186,10 @@ main(int argc, char **argv) fprintf(fo, "\t%u, %u, (pdf_mrange*) cmap_%s_mranges,\n", cmap->mlen, cmap->mlen, name); else fprintf(fo, "\t0, 0, NULL,\n"); + if (cmap->dict) + fprintf(fo, "\t%u, %u, (int*) cmap_%s_dict,\n", cmap->dlen, cmap->dlen, name); + else + fprintf(fo, "\t0, 0, NULL,\n"); fprintf(fo, "};\n"); -- cgit v1.2.3