+
+ /*
+ * Find duplicate charsets
+ */
+ duplicate[0] = -1;
+ for (i = 1; sets[i]; i++)
+ {
+ int j;
+
+ duplicate[i] = -1;
+ for (j = 0; j < i; j++)
+ if (sets[j] == sets[i])
+ {
+ duplicate[i] = j;
+ break;
+ }
+ }
+
+ tn = 0;
+ for (i = 0; sets[i]; i++) {
+ if (duplicate[i] >= 0)
+ continue;
+ off[i] = tn;
+ tn += sets[i]->num;
+ }
+
+ printf ("#define LEAF0 (%d * sizeof (FcLangCharSet))\n", nsets);
+ printf ("#define OFF0 (LEAF0 + %d * sizeof (FcCharLeaf))\n", tl);
+ printf ("#define NUM0 (OFF0 + %d * sizeof (uintptr_t))\n", tn);
+ printf ("#define SET(n) (n * sizeof (FcLangCharSet) + offsetof (FcLangCharSet, charset))\n");
+ printf ("#define OFF(s,o) (OFF0 + o * sizeof (uintptr_t) - SET(s))\n");
+ printf ("#define NUM(s,n) (NUM0 + n * sizeof (FcChar16) - SET(s))\n");
+ printf ("#define LEAF(o,l) (LEAF0 + l * sizeof (FcCharLeaf) - (OFF0 + o * sizeof (intptr_t)))\n");
+ printf ("#define fcLangCharSets (fcLangData.langCharSets)\n");
+ printf ("#define fcLangCharSetIndices (fcLangData.langIndices)\n");
+ printf ("#define fcLangCharSetIndicesInv (fcLangData.langIndicesInv)\n");
+ printf ("\n");
+
+ printf ("static const struct {\n"
+ " FcLangCharSet langCharSets[%d];\n"
+ " FcCharLeaf leaves[%d];\n"
+ " uintptr_t leaf_offsets[%d];\n"
+ " FcChar16 numbers[%d];\n"
+ " FcChar%s langIndices[%d];\n"
+ " FcChar%s langIndicesInv[%d];\n"
+ "} fcLangData = {\n",
+ nsets, tl, tn, tn,
+ nsets < 256 ? "8 " : "16", nsets, nsets < 256 ? "8 " : "16", nsets);
+
+ /*
+ * Dump sets
+ */
+
+ printf ("{\n");
+ for (i = 0; sets[i]; i++)
+ {
+ int j = duplicate[i];
+
+ if (j < 0)
+ j = i;
+
+ printf (" { \"%s\", "
+ " { FC_REF_CONSTANT, %d, OFF(%d,%d), NUM(%d,%d) } }, /* %d */\n",
+ langs[i],
+ sets[j]->num, i, off[j], i, off[j], i);
+ }
+ printf ("},\n");
+