]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcmatch.c
Bug 44826 - <alias> must contain only a single <family>
[fontconfig.git] / src / fcmatch.c
index 594c43712d3fe2eb456256c4836c61ca382397e0..422bc384d2ecbabc2df33e3d10122381d985d9df 100644 (file)
@@ -7,9 +7,9 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
+ * documentation, and that the name of the author(s) not be used in
  * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
+ * specific, written prior permission.  The authors make no
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
@@ -23,6 +23,7 @@
  */
 
 #include "fcint.h"
+#include <assert.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdio.h>
@@ -67,7 +68,7 @@ FcCompareString (FcValue *v1, FcValue *v2)
 static double
 FcCompareFamily (FcValue *v1, FcValue *v2)
 {
-    /* rely on the guarantee in FcPatternAddWithBinding that
+    /* rely on the guarantee in FcPatternObjectAddWithBinding that
      * families are always FcTypeString. */
     const FcChar8* v1_string = FcValueString(v1);
     const FcChar8* v2_string = FcValueString(v2);
@@ -395,6 +396,9 @@ FcFontRenderPrepare (FcConfig           *config,
     FcValue        v;
     FcResult       result;
 
+    assert (pat != NULL);
+    assert (font != NULL);
+
     new = FcPatternCreate ();
     if (!new)
        return 0;
@@ -514,6 +518,10 @@ FcFontSetMatch (FcConfig    *config,
 {
     FcPattern      *best;
 
+    assert (sets != NULL);
+    assert (p != NULL);
+    assert (result != NULL);
+
     if (!config)
     {
        config = FcConfigGetCurrent ();
@@ -536,6 +544,9 @@ FcFontMatch (FcConfig       *config,
     int                nsets;
     FcPattern   *best;
 
+    assert (p != NULL);
+    assert (result != NULL);
+
     if (!config)
     {
        config = FcConfigGetCurrent ();
@@ -672,6 +683,19 @@ FcFontSetSort (FcConfig        *config,
     FcBool         *patternLangSat;
     FcValue        patternLang;
 
+    assert (sets != NULL);
+    assert (p != NULL);
+    assert (result != NULL);
+
+    /* There are some implementation that relying on the result of
+     * "result" to check if the return value of FcFontSetSort
+     * is valid or not.
+     * So we should initialize it to the conservative way since
+     * this function doesn't return NULL anymore.
+     */
+    if (result)
+       *result = FcResultNoMatch;
+
     if (FcDebug () & FC_DBG_MATCH)
     {
        printf ("Sort ");
@@ -686,7 +710,7 @@ FcFontSetSort (FcConfig         *config,
        nnodes += s->nfont;
     }
     if (!nnodes)
-       goto bail0;
+       return FcFontSetCreate ();
 
     for (nPatternLang = 0;
         FcPatternGet (p, FC_LANG, nPatternLang, &patternLang) == FcResultMatch;
@@ -749,7 +773,7 @@ FcFontSetSort (FcConfig         *config,
         * If this node matches any language, go check
         * which ones and satisfy those entries
         */
-       if (nodeps[f]->score[MATCH_LANG_INDEX] < 200)
+       if (nodeps[f]->score[MATCH_LANG_INDEX] < 2000)
        {
            for (i = 0; i < nPatternLang; i++)
            {
@@ -822,6 +846,9 @@ FcFontSort (FcConfig        *config,
     FcFontSet  *sets[2];
     int                nsets;
 
+    assert (p != NULL);
+    assert (result != NULL);
+
     if (!config)
     {
        config = FcConfigGetCurrent ();