summaryrefslogtreecommitdiff
path: root/src/fcmatch.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2013-01-18 11:30:10 +0900
committerAkira TAGOH <akira@tagoh.org>2013-03-21 16:34:42 +0900
commitb561ff2016ce84eef3c81f16dfb0481be6a13f9b (patch)
treec2a58217b36040e9a664587eb28c08230d3f54a1 /src/fcmatch.c
parentc758206e8c0e5b572bd34183b184ef4361745333 (diff)
downloadfontconfig-b561ff2016ce84eef3c81f16dfb0481be6a13f9b.tar.gz
Bug 38737 - Wishlist: support FC_POSTSCRIPT_NAME
Add the PostScript name into the cache and the matcher. Scoring the better font against the PostScript name by the forward-matching.
Diffstat (limited to 'src/fcmatch.c')
-rw-r--r--src/fcmatch.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 7993b81..68f39ae 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -77,6 +77,24 @@ FcCompareFamily (FcValue *v1, FcValue *v2)
}
static double
+FcComparePostScript (FcValue *v1, FcValue *v2)
+{
+ const FcChar8 *v1_string = FcValueString (v1);
+ const FcChar8 *v2_string = FcValueString (v2);
+ int n;
+ size_t len;
+
+ if (FcToLower (*v1_string) != FcToLower (*v2_string) &&
+ *v1_string != ' ' && *v2_string != ' ')
+ return 1.0;
+
+ n = FcStrMatchIgnoreCaseAndDelims (v1_string, v2_string, (const FcChar8 *)" -");
+ len = strlen ((const char *)v1_string);
+
+ return (double)(len - n) / (double)len;
+}
+
+static double
FcCompareLang (FcValue *v1, FcValue *v2)
{
FcLangResult result;
@@ -198,6 +216,7 @@ FcCompareFilename (FcValue *v1, FcValue *v2)
#define PRI_FcCompareFilename(n) PRI1(n)
#define PRI_FcCompareCharSet(n) PRI1(n)
#define PRI_FcCompareLang(n) PRI1(n)
+#define PRI_FcComparePostScript(n) PRI1(n)
#define FC_OBJECT(NAME, Type, Cmp) PRI_##Cmp(NAME)
@@ -219,8 +238,10 @@ typedef enum _FcMatcherPriority {
PRI1(CHARSET),
PRI_FAMILY_STRONG,
PRI_LANG_STRONG,
+ PRI_POSTSCRIPT_NAME_STRONG,
PRI_LANG_WEAK,
PRI_FAMILY_WEAK,
+ PRI_POSTSCRIPT_NAME_WEAK,
PRI1(SPACING),
PRI1(PIXEL_SIZE),
PRI1(STYLE),