]> git.wh0rd.org - fontconfig.git/commitdiff
Change charset enumeration functions to more sensible API
authorKeith Packard <keithp@keithp.com>
Fri, 24 May 2002 05:20:02 +0000 (05:20 +0000)
committerKeith Packard <keithp@keithp.com>
Fri, 24 May 2002 05:20:02 +0000 (05:20 +0000)
fontconfig/fontconfig.h
src/fccharset.c

index 4968aa76cb9f3a7c03b5599aca980f7a8bef9e7d..db4ff3b910c723bdf00a073696c061cbb788648b 100644 (file)
@@ -347,8 +347,19 @@ FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b);
 FcChar32
 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b);
 
+#define FC_CHARSET_MAP_SIZE (256/32)
+#define FC_CHARSET_DONE        ((FcChar32) -1)
+
+FcChar32
+FcCharSetFirstPage (const FcCharSet *a, 
+                   FcChar32        map[FC_CHARSET_MAP_SIZE],
+                   FcChar32        *next);
+
 FcChar32
-FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result);
+FcCharSetNextPage (const FcCharSet  *a, 
+                  FcChar32         map[FC_CHARSET_MAP_SIZE],
+                  FcChar32         *next);
+
 
 /* fcdbg.c */
 void
index 1772cf966adb124278867c28b6e564ecb4e84b21..b0251d7567bbb46b5fb117904c48accaab8d37b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.3 2002/02/18 22:29:28 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.6 2002/03/27 04:33:55 keithp Exp $
  *
  * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -557,27 +557,47 @@ FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b)
     return count;
 }
 
+/*
+ * These two functions efficiently walk the entire charmap for
+ * other software (like pango) that want their own copy
+ */
+
 FcChar32
-FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result)
+FcCharSetNextPage (const FcCharSet  *a, 
+                  FcChar32         map[FC_CHARSET_MAP_SIZE],
+                  FcChar32         *next)
 {
     FcCharSetIter   ai;
+    FcChar32       page;
 
-    ai.ucs4 = page;
+    ai.ucs4 = *next;
     FcCharSetIterSet (a, &ai);
     if (!ai.leaf)
-    {
-       memset (result, '\0', 256 / 8);
-       page = 0;
-    }
-    else
-    {
-       memcpy (result, ai.leaf->map, sizeof (ai.leaf->map));
-       FcCharSetIterNext (a, &ai);
-       page = ai.ucs4;
-    }
+       return FC_CHARSET_DONE;
+    
+    /*
+     * Save current information
+     */
+    page = ai.ucs4;
+    memcpy (map, ai.leaf->map, sizeof (ai.leaf->map));
+    /*
+     * Step to next page
+     */
+    FcCharSetIterNext (a, &ai);
+    *next = ai.ucs4;
+
     return page;
 }
 
+FcChar32
+FcCharSetFirstPage (const FcCharSet *a, 
+                   FcChar32        map[FC_CHARSET_MAP_SIZE],
+                   FcChar32        *next)
+{
+    *next = 0;
+    return FcCharSetNextPage (a, map, next);
+}
+
 /*
  * ASCII representation of charsets.
  *