static void
dump (FcGlyphName * const *table, const char *name)
{
- int i;
+ int i;
- printf ("static const FcGlyphName *%s[%d] = {\n", name, hash);
+ printf ("static const FcGlyphId %s[%d] = {\n", name, hash);
for (i = 0; i < hash; i++)
if (table[i])
- printf ("(FcGlyphName *) &glyph%d,\n", rawindex(table[i]));
+ printf (" %d,\n", rawindex(table[i]));
else
- printf ("0,\n");
+ printf (" -1,\n");
printf ("};\n");
}
char line[1024];
FILE *f;
int i;
+ char *type;
i = 0;
while (argv[i+1])
printf ("#define FC_GLYPHNAME_HASH %u\n", hash);
printf ("#define FC_GLYPHNAME_REHASH %u\n", rehash);
printf ("#define FC_GLYPHNAME_MAXLEN %d\n\n", max_name_len);
+ if (nraw < 128)
+ type = "int8_t";
+ else if (nraw < 32768)
+ type = "int16_t";
+ else
+ type = "int32_t";
+
+ printf ("typedef %s FcGlyphId;\n\n", type);
/*
* Dump out entries
*/
+ printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; } glyphs[%d] = {\n",
+ max_name_len + 1, nraw);
+
for (i = 0; i < nraw; i++)
- printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; }"
- " glyph%d = { 0x%lx, \"%s\" };\n",
- (int) strlen ((char *) raw[i]->name) + 1,
- i, (unsigned long) raw[i]->ucs, raw[i]->name);
+ printf (" { 0x%lx, \"%s\" },\n",
+ (unsigned long) raw[i]->ucs, raw[i]->name);
+
+ printf ("};\n");
/*
* Dump out name_to_ucs table
{
int i = (int) (ucs4 % FC_GLYPHNAME_HASH);
int r = 0;
- const FcGlyphName *gn;
+ FcGlyphId gn;
- while ((gn = ucs_to_name[i]))
+ while ((gn = ucs_to_name[i]) != -1)
{
- if (gn->ucs == ucs4)
- return gn->name;
+ if (glyphs[gn].ucs == ucs4)
+ return glyphs[gn].name;
if (!r)
{
r = (int) (ucs4 % FC_GLYPHNAME_REHASH);
FcChar32 h = FcHashGlyphName (name);
int i = (int) (h % FC_GLYPHNAME_HASH);
int r = 0;
- const FcGlyphName *gn;
+ FcGlyphId gn;
- while ((gn = name_to_ucs[i]))
+ while ((gn = name_to_ucs[i]) != -1)
{
- if (!strcmp ((char *) name, (char *) gn->name))
- return gn->ucs;
+ if (!strcmp ((char *) name, (char *) glyphs[gn].name))
+ return glyphs[gn].ucs;
if (!r)
{
r = (int) (h % FC_GLYPHNAME_REHASH);