]> git.wh0rd.org - fontconfig.git/blobdiff - src/fclist.c
Move existing fonts.conf to fonts.conf.bak
[fontconfig.git] / src / fclist.c
index 5468b2a619598d46164f4a3aaf2626d387d5a9cc..3474d995a031ed9085be502389977426989e2c2a 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fclist.c,v 1.4 2002/06/02 21:07:56 keithp Exp $
+ * $RCSId: xc/lib/fontconfig/src/fclist.c,v 1.11tsi Exp $
  *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2000 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -120,17 +120,33 @@ FcObjectSetBuild (const char *first, ...)
     return os;
 }
 
+/*
+ * Font must have a containing value for every value in the pattern
+ */
 static FcBool
-FcListValueListMatchAny (FcValueList *v1orig,
-                        FcValueList *v2orig)
+FcListValueListMatchAny (FcValueList *patOrig,     /* pattern */
+                        FcValueList *fntOrig)      /* font */
 {
-    FcValueList            *v1, *v2;
+    FcValueList            *pat, *fnt;
 
-    for (v1 = v1orig; v1; v1 = v1->next)
-       for (v2 = v2orig; v2; v2 = v2->next)
-           if (FcConfigCompareValue (v2->value, FcOpContains, v1->value))
-               return FcTrue;
-    return FcFalse;
+    for (pat = patOrig; pat; pat = pat->next)
+    {
+       for (fnt = fntOrig; fnt; fnt = fnt->next)
+       {
+           /*
+            * make sure the font 'contains' the pattern.
+            * (OpListing is OpContains except for strings
+            *  where it requires an exact match)
+            */
+           if (FcConfigCompareValue (fnt->value,
+                                     FcOpListing, 
+                                     pat->value)) 
+               break;
+       }
+       if (!fnt)
+           return FcFalse;
+    }
+    return FcTrue;
 }
 
 static FcBool
@@ -142,7 +158,7 @@ FcListValueListEqual (FcValueList   *v1orig,
     for (v1 = v1orig; v1; v1 = v1->next)
     {
        for (v2 = v2orig; v2; v2 = v2->next)
-           if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value))
+           if (FcValueEqual (v1->value, v2->value))
                break;
        if (!v2)
            return FcFalse;
@@ -150,7 +166,7 @@ FcListValueListEqual (FcValueList   *v1orig,
     for (v2 = v2orig; v2; v2 = v2->next)
     {
        for (v1 = v1orig; v1; v1 = v1->next)
-           if (FcConfigCompareValue (v1->value, FcOpEqual, v2->value))
+           if (FcValueEqual (v1->value, v2->value))
                break;
        if (!v1)
            return FcFalse;
@@ -171,7 +187,7 @@ FcListPatternEqual (FcPattern       *p1,
        e1 = FcPatternFindElt (p1, os->objects[i]);
        e2 = FcPatternFindElt (p2, os->objects[i]);
        if (!e1 && !e2)
-           return FcTrue;
+           continue;
        if (!e1 || !e2)
            return FcFalse;
        if (!FcListValueListEqual (e1->values, e2->values))
@@ -184,9 +200,9 @@ FcListPatternEqual (FcPattern       *p1,
  * FcTrue iff all objects in "p" match "font"
  */
 
-static FcBool
-FcListPatternMatchAny (FcPattern *p,
-                      FcPattern *font)
+FcBool
+FcListPatternMatchAny (const FcPattern *p,
+                      const FcPattern *font)
 {
     int                    i;
     FcPatternElt   *e;
@@ -196,7 +212,8 @@ FcListPatternMatchAny (FcPattern *p,
        e = FcPatternFindElt (font, p->elts[i].object);
        if (!e)
            return FcFalse;
-       if (!FcListValueListMatchAny (p->elts[i].values, e->values))
+       if (!FcListValueListMatchAny (p->elts[i].values,    /* pat elts */
+                                     e->values))           /* font elts */
            return FcFalse;
     }
     return FcTrue;
@@ -246,7 +263,9 @@ FcListValueHash (FcValue    v)
     case FcTypeCharSet:
        return FcCharSetCount (v.u.c);
     case FcTypeFTFace:
-       return (FcChar32) v.u.f;
+       return (long) v.u.f;
+    case FcTypeLangSet:
+       return FcLangSetHash (v.u.l);
     }
     return 0;
 }
@@ -413,7 +432,8 @@ FcFontSetList (FcConfig         *config,
        if (!s)
            continue;
        for (f = 0; f < s->nfont; f++)
-           if (FcListPatternMatchAny (p, s->fonts[f]))
+           if (FcListPatternMatchAny (p,               /* pattern */
+                                      s->fonts[f]))    /* font */
                if (!FcListAppend (&table, s->fonts[f], os))
                    goto bail1;
     }