From 2d39321f1e70a8a1a2a68244b25ca0c7e8c0df3c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 26 Feb 2003 19:13:17 +0000 Subject: [PATCH] Allow double or integer for numeric values in matching --- src/fcdbg.c | 4 ++-- src/fcmatch.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/fcdbg.c b/src/fcdbg.c index 055a8bf..06181d1 100644 --- a/src/fcdbg.c +++ b/src/fcdbg.c @@ -37,10 +37,10 @@ FcValuePrint (const FcValue v) printf (" "); break; case FcTypeInteger: - printf (" %d", v.u.i); + printf (" %d(i)", v.u.i); break; case FcTypeDouble: - printf (" %g", v.u.d); + printf (" %g(f)", v.u.d); break; case FcTypeString: printf (" \"%s\"", v.u.s); diff --git a/src/fcmatch.c b/src/fcmatch.c index 970d0d8..ca2198f 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -28,13 +28,31 @@ #include static double -FcCompareInteger (char *object, FcValue value1, FcValue value2) +FcCompareNumber (char *object, FcValue value1, FcValue value2) { - int v; + double v1, v2, v; - if (value2.type != FcTypeInteger || value1.type != FcTypeInteger) + switch (value1.type) { + case FcTypeInteger: + v1 = (double) value1.u.i; + break; + case FcTypeDouble: + v1 = value1.u.d; + break; + default: return -1.0; - v = value2.u.i - value1.u.i; + } + switch (value2.type) { + case FcTypeInteger: + v2 = (double) value2.u.i; + break; + case FcTypeDouble: + v2 = value2.u.d; + break; + default: + return -1.0; + } + v = v2 - v1; if (v < 0) v = -v; return (double) v; @@ -173,7 +191,7 @@ static FcMatcher _FcMatchers [] = { { FC_LANG, FcCompareLang, 3, 3 }, #define MATCH_LANG 3 - { FC_SPACING, FcCompareInteger, 5, 5 }, + { FC_SPACING, FcCompareNumber, 5, 5 }, #define MATCH_SPACING 4 { FC_PIXEL_SIZE, FcCompareSize, 6, 6 }, @@ -182,10 +200,10 @@ static FcMatcher _FcMatchers [] = { { FC_STYLE, FcCompareString, 7, 7 }, #define MATCH_STYLE 6 - { FC_SLANT, FcCompareInteger, 8, 8 }, + { FC_SLANT, FcCompareNumber, 8, 8 }, #define MATCH_SLANT 7 - { FC_WEIGHT, FcCompareInteger, 9, 9 }, + { FC_WEIGHT, FcCompareNumber, 9, 9 }, #define MATCH_WEIGHT 8 { FC_ANTIALIAS, FcCompareBool, 10, 10 }, @@ -197,7 +215,7 @@ static FcMatcher _FcMatchers [] = { { FC_OUTLINE, FcCompareBool, 12, 12 }, #define MATCH_OUTLINE 11 - { FC_FONTVERSION, FcCompareInteger, 13, 13 }, + { FC_FONTVERSION, FcCompareNumber, 13, 13 }, #define MATCH_FONTVERSION 12 }; -- 2.39.5