From 93c93689f5da4ceaa675e006df63283e25b91d49 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Fri, 4 Dec 2020 18:18:03 +0900 Subject: [PATCH] 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 --- src/fcfreetype.c | 21 ++++++++++++++++++++- src/fcopentype.c | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/fcfreetype.c b/src/fcfreetype.c index a7809cb..4b545bf 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -1087,6 +1087,8 @@ static const FT_UShort nameid_order[] = { TT_NAME_ID_WWS_FAMILY, TT_NAME_ID_TYPOGRAPHIC_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_TYPOGRAPHIC_SUBFAMILY, TT_NAME_ID_FONT_SUBFAMILY, @@ -1222,6 +1224,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face, int nfamily_lang = 0; int nstyle = 0; int nstyle_lang = 0; + int nfullname = 0; + int nfullname_lang = 0; unsigned int p, n; FcChar8 *style = 0; @@ -1443,7 +1447,8 @@ FcFreeTypeQueryFaceInternal (const FT_Face face, * and treat the instance's nameid as FONT_SUBFAMILY. * Postscript name is automatically handled by FreeType. */ 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; if (nameid == TT_NAME_ID_FONT_SUBFAMILY) @@ -1474,6 +1479,20 @@ FcFreeTypeQueryFaceInternal (const FT_Face face, np = &nfamily; nlangp = &nfamily_lang; 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_TYPOGRAPHIC_SUBFAMILY: case TT_NAME_ID_FONT_SUBFAMILY: diff --git a/src/fcopentype.c b/src/fcopentype.c index 9382a1b..59cce45 100644 --- a/src/fcopentype.c +++ b/src/fcopentype.c @@ -76,12 +76,14 @@ FcPatternAddFullname (FcPattern *pat) FcStrBufChar (&sbuf, ' '); FcStrBufString (&sbuf, style); } + FcPatternObjectDel (pat, FC_FULLNAME_OBJECT); if (!FcPatternObjectAddString (pat, FC_FULLNAME_OBJECT, FcStrBufDoneStatic (&sbuf))) { FcStrBufDestroy (&sbuf); return FcFalse; } FcStrBufDestroy (&sbuf); + FcPatternObjectDel (pat, FC_FULLNAMELANG_OBJECT); if (!FcPatternObjectAddString (pat, FC_FULLNAMELANG_OBJECT, (const FcChar8 *) "en")) return FcFalse; }