Replace character discovery loop with simpler, faster version.

The existing loop for discovering which characters map to glyphs is ugly and
inefficient. The replacement is functionally identical, but far cleaner and
faster.
This commit is contained in:
David Turner 2006-09-07 14:29:35 -07:00 committed by Keith Packard
parent 8d779ce4b3
commit 31e0f03210
1 changed files with 33 additions and 56 deletions

View File

@ -2584,32 +2584,12 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
} }
else else
{ {
FT_UInt gindex; page = ~0;
leaf = NULL;
/* ucs4 = FT_Get_First_Char (face, &glyph);
* Find the first encoded character in the font while (glyph != 0)
*/
if (FT_Get_Char_Index (face, 0))
{ {
ucs4 = 0; if (FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance))
gindex = 1;
}
else
{
ucs4 = FT_Get_Next_Char (face, 0, &gindex);
if (!ucs4)
gindex = 0;
}
while (gindex)
{
page = ucs4 >> 8;
leaf = 0;
while ((ucs4 >> 8) == page)
{
glyph = FT_Get_Char_Index (face, ucs4);
if (glyph && FcFreeTypeCheckGlyph (face, ucs4,
glyph, blanks, &advance))
{ {
if (advance) if (advance)
{ {
@ -2631,8 +2611,9 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
} }
} }
if (!leaf) if ((ucs4 >> 8) != page)
{ {
page = (ucs4 >> 8);
leaf = FcCharSetFindLeafCreate (fcs, ucs4); leaf = FcCharSetFindLeafCreate (fcs, ucs4);
if (!leaf) if (!leaf)
goto bail1; goto bail1;
@ -2644,11 +2625,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing)
font_max = ucs4; font_max = ucs4;
#endif #endif
} }
ucs4++; ucs4 = FT_Get_Next_Char (face, ucs4, &glyph);
}
ucs4 = FT_Get_Next_Char (face, ucs4 - 1, &gindex);
if (!ucs4)
gindex = 0;
} }
#ifdef CHECK #ifdef CHECK
for (ucs4 = 0; ucs4 < 0x10000; ucs4++) for (ucs4 = 0; ucs4 < 0x10000; ucs4++)