Commit 452be812 authored by Akira TAGOH's avatar Akira TAGOH

Add proper fullname for named-instances

Try to build a fullname from a family and a style name for a named-instance.

Fixes #185
parent 8bddcb11
Pipeline #110141 passed with stage
in 4 minutes and 31 seconds
......@@ -1495,7 +1495,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_PREFERRED_SUBFAMILY)
nameid == TT_NAME_ID_PREFERRED_SUBFAMILY ||
nameid == TT_NAME_ID_FULL_NAME)
continue;
if (nameid == TT_NAME_ID_FONT_SUBFAMILY)
......@@ -1681,6 +1682,61 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
++nfamily;
}
/* Add the fullname into the cache */
if (!variable && !nfullname)
{
FcChar8 *family, *style, *lang;
int n = 0;
size_t len, i;
FcStrBuf sbuf;
while (FcPatternObjectGetString (pat, FC_FAMILYLANG_OBJECT, n, &lang) == FcResultMatch)
{
if (FcStrCmp (lang, (const FcChar8 *) "en") == 0)
break;
n++;
lang = NULL;
}
if (!lang)
n = 0;
if (FcPatternObjectGetString (pat, FC_FAMILY_OBJECT, n, &family) != FcResultMatch)
goto bail1;
len = strlen ((const char *) family);
for (i = len; i > 0; i--)
{
if (!isspace (family[i]))
break;
}
family[i] = 0;
while (FcPatternObjectGetString (pat, FC_STYLELANG_OBJECT, n, &lang) == FcResultMatch)
{
if (FcStrCmp (lang, (const FcChar8 *) "en") == 0)
break;
n++;
lang = NULL;
}
if (!lang)
n = 0;
if (FcPatternObjectGetString (pat, FC_STYLE_OBJECT, n, &style) != FcResultMatch)
goto bail1;
len = strlen ((const char *) style);
for (i = 0; style[i] != 0 && isspace (style[i]); i++)
break;
memcpy (style, &style[i], len - i);
FcStrBufInit (&sbuf, NULL, 0);
FcStrBufString (&sbuf, family);
FcStrBufChar (&sbuf, ' ');
FcStrBufString (&sbuf, style);
if (!FcPatternObjectAddString (pat, FC_FULLNAME_OBJECT, FcStrBufDoneStatic (&sbuf)))
{
FcStrBufDestroy (&sbuf);
goto bail1;
}
FcStrBufDestroy (&sbuf);
if (!FcPatternObjectAddString (pat, FC_FULLNAMELANG_OBJECT, (const FcChar8 *) "en"))
goto bail1;
++nfullname;
}
/* Add the PostScript name into the cache */
if (!variable)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment