]> git.wh0rd.org - fontconfig.git/commitdiff
[fcmatch] Move FcFontSetMatch() functionality into FcFontSetMatchInternal()
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 1 Jan 2009 01:16:40 +0000 (20:16 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 14 Feb 2009 00:54:05 +0000 (16:54 -0800)
Except for the final FcFontRenderPrepare().  This way we have more
flexibility to do caching in FcFontMatch() while leaving FcFontSetMatch()
intact.

src/fcmatch.c

index 49dd0ddae78771f6daf7be4c223adee9698671ad..556fffeaa85a6aba69d9819008c5a2fd90e4b0ad 100644 (file)
@@ -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];
@@ -537,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);
 }
 
@@ -547,6 +560,7 @@ FcFontMatch (FcConfig       *config,
 {
     FcFontSet  *sets[2];
     int                nsets;
+    FcPattern   *best;
 
     if (!config)
     {
@@ -559,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 {