From: Keith Packard Date: Sat, 2 Sep 2006 03:25:21 +0000 (-0700) Subject: Match 'ultra' on word boundaries to detect ultra bold fonts. (bug 2511) X-Git-Tag: 2.4.91~4 X-Git-Url: https://git.wh0rd.org/?p=fontconfig.git;a=commitdiff_plain;h=4ee9ca67867ec9517c90d6947bb88d3f25707746 Match 'ultra' on word boundaries to detect ultra bold fonts. (bug 2511) Added FcStrContainsWord to detect strings on word boundaries. --- diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 3265a38..572e7f2 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -959,8 +959,18 @@ FcStringContainsConst (const FcChar8 *string, int i; for (i = 0; i < nc; i++) - if (FcStrContainsIgnoreBlanksAndCase (string, c[i].name)) - return c[i].value; + { + if (c[i].name[0] == '<') + { + if (FcStrContainsWord (string, c[i].name + 1)) + return c[i].value; + } + else + { + if (FcStrContainsIgnoreBlanksAndCase (string, c[i].name)) + return c[i].value; + } + } return -1; } @@ -985,6 +995,7 @@ static const FcStringConst weightConsts[] = { { (FC8) "ultrablack", FC_WEIGHT_ULTRABLACK }, { (FC8) "superblack", FC_WEIGHT_EXTRABLACK }, { (FC8) "extrablack", FC_WEIGHT_EXTRABLACK }, + { (FC8) "= s2len) + { + if (wordStart && + FcStrIsAtIgnoreCase (s1, s2) && + (s1len == s2len || FcCharIsPunct (s1[s2len]))) + { + return s1; + } + wordStart = FcFalse; + if (FcCharIsPunct (*s1)) + wordStart = FcTrue; + s1++; + s1len--; + } + return 0; +} + const FcChar8 * FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2) {