From 4ee9ca67867ec9517c90d6947bb88d3f25707746 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 1 Sep 2006 20:25:21 -0700 Subject: [PATCH] Match 'ultra' on word boundaries to detect ultra bold fonts. (bug 2511) Added FcStrContainsWord to detect strings on word boundaries. --- src/fcfreetype.c | 15 +++++++++++++-- src/fcint.h | 3 +++ src/fcstr.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) 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) { -- 2.39.2