Call FT_Get_Advance() only as long as we need to determine font width type

This commit is contained in:
Behdad Esfahbod 2017-08-04 17:40:06 +01:00
parent ad0a82b8f8
commit 60b2cf8e4c
1 changed files with 12 additions and 11 deletions

View File

@ -2077,7 +2077,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
{ {
FcCharSet *fcs; FcCharSet *fcs;
int o; int o;
FT_Pos advance, advances[3]; FT_Pos advances[3];
unsigned int num_advances = 0; unsigned int num_advances = 0;
fcs = FcCharSetCreate (); fcs = FcCharSetCreate ();
@ -2133,9 +2133,6 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
if (face->face_flags & FT_FACE_FLAG_SCALABLE) if (face->face_flags & FT_FACE_FLAG_SCALABLE)
load_flags |= FT_LOAD_NO_BITMAP; load_flags |= FT_LOAD_NO_BITMAP;
advance = 0;
FT_Get_Advance (face, glyph, load_flags, &advance);
/* CID fonts built by Adobe used to make ASCII control chars to cid1 /* CID fonts built by Adobe used to make ASCII control chars to cid1
* (space glyph). As such, always check contour for those characters. */ * (space glyph). As such, always check contour for those characters. */
if (ucs4 <= 0x001F) if (ucs4 <= 0x001F)
@ -2148,14 +2145,18 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
if (good) if (good)
{ {
if (num_advances < 3 && advance) if (num_advances < 3)
{ {
unsigned int i; FT_Pos advance = 0;
for (i = 0; i < num_advances; i++) if (!FT_Get_Advance (face, glyph, load_flags, &advance) && advance)
if (fc_approximately_equal (advance, advances[i])) {
break; unsigned int i;
if (i == num_advances) for (i = 0; i < num_advances; i++)
advances[num_advances++] = advance; if (fc_approximately_equal (advance, advances[i]))
break;
if (i == num_advances)
advances[num_advances++] = advance;
}
} }
if ((ucs4 >> 8) != page) if ((ucs4 >> 8) != page)