From 4e21e6f6e6381420b4559cf1c530ec9060ddeb21 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 | 16 ++++++++++++++-- src/fcint.h | 3 +++ src/fcstr.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 3cf1686..d93292d 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -935,8 +935,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; } @@ -958,6 +968,8 @@ static const FcStringConst weightConsts[] = { { (FC8) "superbold", FC_WEIGHT_EXTRABOLD }, { (FC8) "ultrabold", FC_WEIGHT_ULTRABOLD }, { (FC8) "bold", FC_WEIGHT_BOLD }, + { (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) {