Improve the performance a bit
This commit is contained in:
parent
322131f433
commit
cb3e6ff4d7
|
@ -1101,13 +1101,20 @@ FcGetPixelSize (FT_Face face, int i)
|
|||
}
|
||||
|
||||
static FcBool
|
||||
FcStringInPatternElement (FcPattern *pat, const char *elt, FcChar8 *string)
|
||||
FcStringInPatternElement (FcPattern *pat, FcObject obj, const FcChar8 *string)
|
||||
{
|
||||
int e;
|
||||
FcChar8 *old;
|
||||
for (e = 0; FcPatternGetString (pat, elt, e, &old) == FcResultMatch; e++)
|
||||
if (!FcStrCmpIgnoreBlanksAndCase (old, string))
|
||||
FcPatternIter iter;
|
||||
FcValueListPtr l;
|
||||
|
||||
FcPatternIterStart (pat, &iter);
|
||||
if (!FcPatternFindObjectIter (pat, &iter, obj))
|
||||
return FcFalse;
|
||||
for (l = FcPatternIterGetValues (pat, &iter); l; l = FcValueListNext (l))
|
||||
{
|
||||
FcValue v = FcValueCanonicalize (&l->value);
|
||||
if (v.type != FcTypeString)
|
||||
break;
|
||||
if (!FcStrCmpIgnoreBlanksAndCase (v.u.s, string))
|
||||
return FcTrue;
|
||||
}
|
||||
return FcFalse;
|
||||
|
@ -1455,10 +1462,10 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
FT_SfntName sname;
|
||||
int nameidx;
|
||||
const FcChar8 *lang;
|
||||
const char *elt = 0, *eltlang = 0;
|
||||
int *np = 0, *nlangp = 0;
|
||||
size_t len;
|
||||
int nameid, lookupid;
|
||||
FcObject obj = FC_INVALID_OBJECT, objlang = FC_INVALID_OBJECT;
|
||||
|
||||
nameid = lookupid = nameid_order[n];
|
||||
|
||||
|
@ -1494,8 +1501,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
sname.name_id, sname.platform_id,
|
||||
sname.encoding_id, sname.language_id);
|
||||
|
||||
elt = FC_FAMILY;
|
||||
eltlang = FC_FAMILYLANG;
|
||||
obj = FC_FAMILY_OBJECT;
|
||||
objlang = FC_FAMILYLANG_OBJECT;
|
||||
np = &nfamily;
|
||||
nlangp = &nfamily_lang;
|
||||
break;
|
||||
|
@ -1506,8 +1513,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
sname.name_id, sname.platform_id,
|
||||
sname.encoding_id, sname.language_id);
|
||||
|
||||
elt = FC_FULLNAME;
|
||||
eltlang = FC_FULLNAMELANG;
|
||||
obj = FC_FULLNAME_OBJECT;
|
||||
objlang = FC_FULLNAMELANG_OBJECT;
|
||||
np = &nfullname;
|
||||
nlangp = &nfullname_lang;
|
||||
break;
|
||||
|
@ -1521,8 +1528,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
sname.name_id, sname.platform_id,
|
||||
sname.encoding_id, sname.language_id);
|
||||
|
||||
elt = FC_STYLE;
|
||||
eltlang = FC_STYLELANG;
|
||||
obj = FC_STYLE_OBJECT;
|
||||
objlang = FC_STYLELANG_OBJECT;
|
||||
np = &nstyle;
|
||||
nlangp = &nstyle_lang;
|
||||
break;
|
||||
|
@ -1538,7 +1545,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (elt)
|
||||
if (obj != FC_INVALID_OBJECT)
|
||||
{
|
||||
FcChar8 *utf8, *pp;
|
||||
|
||||
|
@ -1562,14 +1569,14 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
pp--;
|
||||
*pp = 0;
|
||||
|
||||
if (FcStringInPatternElement (pat, elt, utf8))
|
||||
if (FcStringInPatternElement (pat, obj, utf8))
|
||||
{
|
||||
free (utf8);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* add new element */
|
||||
if (!FcPatternAddString (pat, elt, utf8))
|
||||
if (!FcPatternObjectAddString (pat, obj, utf8))
|
||||
{
|
||||
free (utf8);
|
||||
goto bail1;
|
||||
|
@ -1580,11 +1587,11 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
|
|||
/* pad lang list with 'und' to line up with elt */
|
||||
while (*nlangp < *np)
|
||||
{
|
||||
if (!FcPatternAddString (pat, eltlang, (FcChar8 *) "und"))
|
||||
if (!FcPatternObjectAddString (pat, objlang, (FcChar8 *) "und"))
|
||||
goto bail1;
|
||||
++*nlangp;
|
||||
}
|
||||
if (!FcPatternAddString (pat, eltlang, lang))
|
||||
if (!FcPatternObjectAddString (pat, objlang, lang))
|
||||
goto bail1;
|
||||
++*nlangp;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue