From: Keith Packard Date: Fri, 24 May 2002 05:20:02 +0000 (+0000) Subject: Change charset enumeration functions to more sensible API X-Git-Tag: xf-4_2_99_1~15 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=36732012151a91527f3ad7ad05569f40a0ca3cd9;p=fontconfig.git Change charset enumeration functions to more sensible API --- diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 4968aa7..db4ff3b 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -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 diff --git a/src/fccharset.c b/src/fccharset.c index 1772cf9..b0251d7 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -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. *