]> git.wh0rd.org - fontconfig.git/commitdiff
Allow double or integer for numeric values in matching
authorKeith Packard <keithp@keithp.com>
Wed, 26 Feb 2003 19:13:17 +0000 (19:13 +0000)
committerKeith Packard <keithp@keithp.com>
Wed, 26 Feb 2003 19:13:17 +0000 (19:13 +0000)
src/fcdbg.c
src/fcmatch.c

index 055a8bf8ea99a309d5314057a0ade8a63d8381b3..06181d1efa7f2603f594907cc7c03633e995b39c 100644 (file)
@@ -37,10 +37,10 @@ FcValuePrint (const FcValue v)
        printf (" <void>");
        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);
index 970d0d873d590a0a5dd4a97095546784bb3fc883..ca2198f56e36112e59156c3dc2dcc3359edf4f6e 100644 (file)
 #include <stdio.h>
 
 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
 };