]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcmatch.c
Global cache time checking was using wrong file name and computing wrong
[fontconfig.git] / src / fcmatch.c
index 20c0861a890d84eb80b35328c4efab62e10f6b24..6ec500adb89042068135ae1882350079232271c8 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.18 2002/08/19 19:32:05 keithp Exp $
+ * $RCSId: xc/lib/fontconfig/src/fcmatch.c,v 1.20 2002/08/31 22:17:32 keithp Exp $
  *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2000 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 #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;
+    }
+    switch (value2.type) {
+    case FcTypeInteger:
+       v2 = (double) value2.u.i;
+       break;
+    case FcTypeDouble:
+       v2 = value2.u.d;
+       break;
+    default:
        return -1.0;
-    v = value2.u.i - value1.u.i;
+    }
+    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 },
@@ -196,9 +214,12 @@ static FcMatcher _FcMatchers [] = {
     
     { FC_OUTLINE,      FcCompareBool,          12, 12 },
 #define MATCH_OUTLINE      11
+
+    { FC_FONTVERSION,  FcCompareNumber,        13, 13 },
+#define MATCH_FONTVERSION   12
 };
 
-#define NUM_MATCH_VALUES    13
+#define NUM_MATCH_VALUES    14
 
 static FcBool
 FcCompareValueList (const char  *object,
@@ -222,7 +243,13 @@ FcCompareValueList (const char  *object,
     case 'f':
        switch (FcToLower (object[1])) {
        case 'o':
-           i = MATCH_FOUNDRY; break;
+           switch (FcToLower (object[2])) {
+           case 'u':
+               i = MATCH_FOUNDRY; break;
+           case 'n':
+               i = MATCH_FONTVERSION; break;
+           }
+           break;
        case 'a':
            i = MATCH_FAMILY; break;
        }
@@ -640,6 +667,7 @@ FcFontSetSort (FcConfig         *config,
     }
     if (!nnodes)
        goto bail0;
+    /* freed below */
     nodes = malloc (nnodes * sizeof (FcSortNode) + nnodes * sizeof (FcSortNode *));
     if (!nodes)
        goto bail0;