Add back fullname property at scan matching phase

There seems to be a lot of config files using fullname property in the world.
To keep the backward compatibility, fullname property is back to a cache at
the scan matching phase but will be rebuilt once it is done according to family
and style property in the pattern no matter what changes one made in fullname
property during that.

Ref. https://bugzilla.redhat.com/show_bug.cgi?id=1902881
This commit is contained in:
Akira TAGOH 2020-12-04 18:18:03 +09:00
parent d06103e3e7
commit 93c93689f5
2 changed files with 22 additions and 1 deletions

View File

@ -1087,6 +1087,8 @@ static const FT_UShort nameid_order[] = {
TT_NAME_ID_WWS_FAMILY, TT_NAME_ID_WWS_FAMILY,
TT_NAME_ID_TYPOGRAPHIC_FAMILY, TT_NAME_ID_TYPOGRAPHIC_FAMILY,
TT_NAME_ID_FONT_FAMILY, TT_NAME_ID_FONT_FAMILY,
TT_NAME_ID_MAC_FULL_NAME,
TT_NAME_ID_FULL_NAME,
TT_NAME_ID_WWS_SUBFAMILY, TT_NAME_ID_WWS_SUBFAMILY,
TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY, TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY,
TT_NAME_ID_FONT_SUBFAMILY, TT_NAME_ID_FONT_SUBFAMILY,
@ -1222,6 +1224,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
int nfamily_lang = 0; int nfamily_lang = 0;
int nstyle = 0; int nstyle = 0;
int nstyle_lang = 0; int nstyle_lang = 0;
int nfullname = 0;
int nfullname_lang = 0;
unsigned int p, n; unsigned int p, n;
FcChar8 *style = 0; FcChar8 *style = 0;
@ -1443,7 +1447,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
* and treat the instance's nameid as FONT_SUBFAMILY. * and treat the instance's nameid as FONT_SUBFAMILY.
* Postscript name is automatically handled by FreeType. */ * Postscript name is automatically handled by FreeType. */
if (nameid == TT_NAME_ID_WWS_SUBFAMILY || if (nameid == TT_NAME_ID_WWS_SUBFAMILY ||
nameid == TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY) nameid == TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY ||
nameid == TT_NAME_ID_FULL_NAME)
continue; continue;
if (nameid == TT_NAME_ID_FONT_SUBFAMILY) if (nameid == TT_NAME_ID_FONT_SUBFAMILY)
@ -1474,6 +1479,20 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
np = &nfamily; np = &nfamily;
nlangp = &nfamily_lang; nlangp = &nfamily_lang;
break; break;
case TT_NAME_ID_MAC_FULL_NAME:
case TT_NAME_ID_FULL_NAME:
if (variable)
break;
if (FcDebug () & FC_DBG_SCANV)
printf ("found full (n %2d p %d e %d l 0x%04x)",
sname.name_id, sname.platform_id,
sname.encoding_id, sname.language_id);
obj = FC_FULLNAME_OBJECT;
objlang = FC_FULLNAMELANG_OBJECT;
np = &nfullname;
nlangp = &nfullname_lang;
break;
case TT_NAME_ID_WWS_SUBFAMILY: case TT_NAME_ID_WWS_SUBFAMILY:
case TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY: case TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY:
case TT_NAME_ID_FONT_SUBFAMILY: case TT_NAME_ID_FONT_SUBFAMILY:

View File

@ -76,12 +76,14 @@ FcPatternAddFullname (FcPattern *pat)
FcStrBufChar (&sbuf, ' '); FcStrBufChar (&sbuf, ' ');
FcStrBufString (&sbuf, style); FcStrBufString (&sbuf, style);
} }
FcPatternObjectDel (pat, FC_FULLNAME_OBJECT);
if (!FcPatternObjectAddString (pat, FC_FULLNAME_OBJECT, FcStrBufDoneStatic (&sbuf))) if (!FcPatternObjectAddString (pat, FC_FULLNAME_OBJECT, FcStrBufDoneStatic (&sbuf)))
{ {
FcStrBufDestroy (&sbuf); FcStrBufDestroy (&sbuf);
return FcFalse; return FcFalse;
} }
FcStrBufDestroy (&sbuf); FcStrBufDestroy (&sbuf);
FcPatternObjectDel (pat, FC_FULLNAMELANG_OBJECT);
if (!FcPatternObjectAddString (pat, FC_FULLNAMELANG_OBJECT, (const FcChar8 *) "en")) if (!FcPatternObjectAddString (pat, FC_FULLNAMELANG_OBJECT, (const FcChar8 *) "en"))
return FcFalse; return FcFalse;
} }