]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcmatch.c
Oops, fix FcPatternFilter
[fontconfig.git] / src / fcmatch.c
index e46eefe87766e36535dbcfc077d1028101cae492..556fffeaa85a6aba69d9819008c5a2fd90e4b0ad 100644 (file)
@@ -317,7 +317,7 @@ FcCompareValueList (FcObject         object,
     best = 1e99;
     bestStrong = 1e99;
     bestWeak = 1e99;
-    j = 0;
+    j = 1;
     for (v1 = v1orig; v1; v1 = FcValueListNext(v1))
     {
        for (v2 = v2orig; v2; v2 = FcValueListNext(v2))
@@ -328,7 +328,7 @@ FcCompareValueList (FcObject         object,
                *result = FcResultTypeMismatch;
                return FcFalse;
            }
-           v = v * 100 + j;
+           v = v * 1000 + j;
            if (v < best)
            {
                if (bestValue)
@@ -459,12 +459,12 @@ FcFontRenderPrepare (FcConfig         *config,
     return new;
 }
 
-FcPattern *
-FcFontSetMatch (FcConfig    *config,
-               FcFontSet   **sets,
-               int         nsets,
-               FcPattern   *p,
-               FcResult    *result)
+static FcPattern *
+FcFontSetMatchInternal (FcConfig    *config,
+                       FcFontSet   **sets,
+                       int         nsets,
+                       FcPattern   *p,
+                       FcResult    *result)
 {
     double         score[NUM_MATCH_VALUES], bestscore[NUM_MATCH_VALUES];
     int                    f;
@@ -481,12 +481,6 @@ FcFontSetMatch (FcConfig    *config,
        printf ("Match ");
        FcPatternPrint (p);
     }
-    if (!config)
-    {
-       config = FcConfigGetCurrent ();
-       if (!config)
-           return 0;
-    }
     for (set = 0; set < nsets; set++)
     {
        s = sets[set];
@@ -529,6 +523,7 @@ FcFontSetMatch (FcConfig    *config,
        printf ("Best score");
        for (i = 0; i < NUM_MATCH_VALUES; i++)
            printf (" %g", bestscore[i]);
+       printf ("\n");
        FcPatternPrint (best);
     }
     if (!best)
@@ -536,6 +531,25 @@ FcFontSetMatch (FcConfig    *config,
        *result = FcResultNoMatch;
        return 0;
     }
+    return best;
+}
+
+FcPattern *
+FcFontSetMatch (FcConfig    *config,
+               FcFontSet   **sets,
+               int         nsets,
+               FcPattern   *p,
+               FcResult    *result)
+{
+    FcPattern      *best;
+
+    if (!config)
+    {
+       config = FcConfigGetCurrent ();
+       if (!config)
+           return 0;
+    }
+    best = FcFontSetMatchInternal (config, sets, nsets, p, result);
     return FcFontRenderPrepare (config, p, best);
 }
 
@@ -546,6 +560,7 @@ FcFontMatch (FcConfig       *config,
 {
     FcFontSet  *sets[2];
     int                nsets;
+    FcPattern   *best;
 
     if (!config)
     {
@@ -558,7 +573,9 @@ FcFontMatch (FcConfig       *config,
        sets[nsets++] = config->fonts[FcSetSystem];
     if (config->fonts[FcSetApplication])
        sets[nsets++] = config->fonts[FcSetApplication];
-    return FcFontSetMatch (config, sets, nsets, p, result);
+
+    best = FcFontSetMatchInternal (config, sets, nsets, p, result);
+    return FcFontRenderPrepare (config, p, best);
 }
 
 typedef struct _FcSortNode {
@@ -767,7 +784,7 @@ FcFontSetSort (FcConfig         *config,
            }
        }
        if (!satisfies)
-           nodeps[f]->score[MATCH_LANG_INDEX] = 1000.0;
+           nodeps[f]->score[MATCH_LANG_INDEX] = 10000.0;
     }
 
     /*