]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcmatch.c
[fcmatch] Use larger multipliers to enforce order
[fontconfig.git] / src / fcmatch.c
index 77b49cf181a2b41b004e463c4aea8a77c3ca0b38..4d20a61fc9b7f09d702f4bb8641b69dee8ff9386 100644 (file)
@@ -72,7 +72,8 @@ FcCompareFamily (FcValue *v1, FcValue *v2)
     const FcChar8* v1_string = fc_value_string(v1);
     const FcChar8* v2_string = fc_value_string(v2);
 
-    if (FcToLower(*v1_string) != FcToLower(*v2_string))
+    if (FcToLower(*v1_string) != FcToLower(*v2_string) &&
+       *v1_string != ' ' && *v2_string != ' ')
        return 1.0;
 
     return (double) FcStrCmpIgnoreBlanksAndCase (v1_string, v2_string) != 0;
@@ -327,7 +328,7 @@ FcCompareValueList (FcObject         object,
                *result = FcResultTypeMismatch;
                return FcFalse;
            }
-           v = v * 100 + j;
+           v = v * 1000 + j;
            if (v < best)
            {
                if (bestValue)
@@ -528,6 +529,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)
@@ -590,33 +592,40 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool tri
     while (nnode--)
     {
        node = *n++;
-       if (FcPatternGetCharSet (node->pattern, FC_CHARSET, 0, &ncs) == 
-           FcResultMatch)
+
+       /*
+        * Only fetch node charset if we'd need it
+        */
+       if (trim || build_cs)
+       {
+           if (FcPatternGetCharSet (node->pattern, FC_CHARSET, 0, &ncs) !=
+               FcResultMatch)
+               continue;
+       }
+
+       /*
+        * If this font isn't a subset of the previous fonts,
+        * add it to the list
+        */
+       if (!trim || !*cs || !FcCharSetIsSubset (ncs, *cs))
        {
-           /*
-            * If this font isn't a subset of the previous fonts,
-            * add it to the list
-            */
-           if (!trim || !*cs || !FcCharSetIsSubset (ncs, *cs))
+           if (trim || build_cs)
            {
-                if (trim || build_cs)
-                {
-                   *cs = FcCharSetMerge (*cs, ncs);
-                   if (*cs == NULL)
-                       return FcFalse;
-                }
-
-               FcPatternReference (node->pattern);
-               if (FcDebug () & FC_DBG_MATCHV)
-               {
-                   printf ("Add ");
-                   FcPatternPrint (node->pattern);
-               }
-               if (!FcFontSetAdd (fs, node->pattern))
-               {
-                   FcPatternDestroy (node->pattern);
+               *cs = FcCharSetMerge (*cs, ncs);
+               if (*cs == NULL)
                    return FcFalse;
-               }
+           }
+
+           FcPatternReference (node->pattern);
+           if (FcDebug () & FC_DBG_MATCHV)
+           {
+               printf ("Add ");
+               FcPatternPrint (node->pattern);
+           }
+           if (!FcFontSetAdd (fs, node->pattern))
+           {
+               FcPatternDestroy (node->pattern);
+               return FcFalse;
            }
        }
     }
@@ -759,7 +768,7 @@ FcFontSetSort (FcConfig         *config,
            }
        }
        if (!satisfies)
-           nodeps[f]->score[MATCH_LANG_INDEX] = 1000.0;
+           nodeps[f]->score[MATCH_LANG_INDEX] = 10000.0;
     }
 
     /*