]> git.wh0rd.org - fontconfig.git/blobdiff - src/fclist.c
Change files from ISO-Latin-1 to UTF-8
[fontconfig.git] / src / fclist.c
index 414af11b61884de294a7afd38820313b5d5931cb..18d7e711df12ae454a3eac475afdd0183800f405 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
@@ -80,7 +80,8 @@ FcObjectSetAdd (FcObjectSet *os, const char *object)
     }
     if (c < 0)
        mid++;
-    memmove (os->objects + mid + 1, os->objects + mid, os->nobject - mid);
+    memmove (os->objects + mid + 1, os->objects + mid, 
+            (os->nobject - mid) * sizeof (const char *));
     os->objects[mid] = object;
     os->nobject++;
     return FcTrue;
@@ -119,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
@@ -141,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;
@@ -149,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;
@@ -170,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))
@@ -183,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;
@@ -195,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;
@@ -245,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;
 }
@@ -412,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;
     }