]> git.wh0rd.org Git - fontconfig.git/commitdiff
Stephan Kulow <coolo@suse.de> reviewed by: plam
authorPatrick Lam <plam@MIT.EDU>
Mon, 28 Nov 2005 10:54:11 +0000 (10:54 +0000)
committerPatrick Lam <plam@MIT.EDU>
Mon, 28 Nov 2005 10:54:11 +0000 (10:54 +0000)
Don't kill all fonts during match (oops!)

ChangeLog
src/fcmatch.c

index 9a4cf7622d6301d2a1a6ef09ef12756693061778..7c402be46b0e5932c0a3b7d989df24170d9283d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-11-28  Dirk Mueller  <dmueller@suse.com>
+           Stephan Kulow  <coolo@suse.de>
+       reviewed by: plam
+
+       * src/fcmatch.c (FcFontSetMatch):
+
+       Don't kill all fonts during match (oops!)
+
+
+2005-11-25  Dirk Mueller  <dmueller@suse.com>
+            Stephan Kulow  <coolo@suse.de>
+            Michael Matz  <matz@suse.de>
+        reviewed by: plam
+
+        * src/fcmatch.c (FcObjectPtrToMatcher, FcCompareValueList,
+                FcFontSetMatch):
+
+        Rewrite FcFontSetMatch to a path-finding based algorithm, i.e.
+        inline FcCompare into FcFontSetMatch and reorder the
+        loops, adding a boolean array which blocks patterns from future
+        consideration if they're known to not be best on some past
+        criterion.
+
 2005-11-26  Dirk Mueller  <dmueller@suse.com>
        reviewed by: plam
        
index 0af0c8367d68dd50f56a560d8f486e0940ea50cc..93e3860a98dbdaf28c813dd3ed89663ca375c877 100644 (file)
@@ -534,11 +534,15 @@ FcFontSetMatch (FcConfig    *config,
     }
     for (set = 0; set < nsets; set++)
     {
+       FcBool        *matchBlocked;
+       int           blockStart;
+
        s = sets[set];
        if (!s)
            continue;
 
-        char* matchBlocked = (char*)calloc(s->nfont, sizeof(FcBool));
+       matchBlocked = (FcBool*)calloc(s->nfont, sizeof(FcBool));
+       blockStart = 0;
 
        /* The old algorithm checked if each font beat 'best', 
         * scanning all of the value lists for all of the pattern elts. */
@@ -575,19 +579,29 @@ FcFontSetMatch (FcConfig    *config,
            if (!match)
                continue;
 
-            bestscore = 1e99;
-
-            
             for (v1 = pat_elts[pat_elt].values, v1_ptrU = FcValueListPtrU(v1); 
                 v1_ptrU;
                  v1 = FcValueListPtrU(v1)->next, 
                     v1_ptrU = FcValueListPtrU(v1), v1_offset++)
             {
-
-               if (v1_ptrU->binding == FcValueBindingWeak
+               if ((v1_ptrU->binding == FcValueBindingWeak
                     && scoring_index != match->weak)
+                    || (v1_ptrU->binding == FcValueBindingStrong 
+                        && scoring_index != match->strong)
+                    )
                    continue;
 
+               bestscore = 1e99;
+
+               if (FcDebug () & FC_DBG_MATCHV)
+               {
+                       int blocked_fonts = 0;
+                       for (f = 0; f < s->nfont; f++)
+                               blocked_fonts += matchBlocked[f] ? 1 : 0;
+                       printf("Scoring Index %d, Value %d: %d(%d) fonts left\n", 
+                               scoring_index, v1_offset, s->nfont - blocked_fonts, s->nfont);  
+               }
+
                for (f = 0; f < s->nfont; f++)
                {
                    int                 cand_elt;
@@ -644,12 +658,13 @@ FcFontSetMatch (FcConfig    *config,
                        if (best) 
                        {
                            int b;
-                           for (b = 0; b < f; ++b)
+                           for (b = blockStart; b < f; ++b)
                                matchBlocked[b] = FcTrue;
                        }
 
                        bestscore = score;
                        best = s->fonts[f];
+                       blockStart = f;
                    }
 
                    /* If f loses, then it's out too. */
@@ -659,10 +674,20 @@ FcFontSetMatch (FcConfig    *config,
                    /* Otherwise, f is equal to best on this element.
                     * Carry on to next pattern element. */
                }
+               if ((FcDebug () & FC_DBG_MATCHV) && best)
+               {
+                   printf ("Best match (scoring index %d) candidate ", scoring_index);
+                   FcPatternPrint (best);
+               }
            }
         }
        free (matchBlocked);
     }
+    if ((FcDebug () & FC_DBG_MATCH) && best)
+    {
+       printf ("Best match ");
+       FcPatternPrint (best);
+    }
     if (!best)
     {
        *result = FcResultNoMatch;