From: Behdad Esfahbod Date: Tue, 21 Sep 2010 17:14:41 +0000 (-0400) Subject: Add new public API: FcCharSetDelChar() X-Git-Tag: root-2~47 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=52960d05ebb8af34a302e3959978d2930a39fb39;p=fontconfig.git Add new public API: FcCharSetDelChar() --- diff --git a/doc/fccharset.fncs b/doc/fccharset.fncs index b12064a..004fdc3 100644 --- a/doc/fccharset.fncs +++ b/doc/fccharset.fncs @@ -51,6 +51,17 @@ returning FcFalse on failure, either as a result of a constant set or from running out of memory. @@ +@RET@ FcBool +@FUNC@ FcCharSetDelChar +@TYPE1@ FcCharSet * @ARG1@ fcs +@TYPE2@ FcChar32% @ARG2@ ucs4 +@PURPOSE@ Add a character to a charset +@DESC@ +FcCharSetDelChar deletes a single unicode char from the set, +returning FcFalse on failure, either as a result of a constant set or from +running out of memory. +@@ + @RET@ FcCharSet * @FUNC@ FcCharSetCopy @TYPE1@ FcCharSet * @ARG1@ src diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index c9f20cc..6a6d511 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -423,6 +423,9 @@ FcCharSetDestroy (FcCharSet *fcs); FcPublic FcBool FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4); +FcPublic FcBool +FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4); + FcPublic FcCharSet* FcCharSetCopy (FcCharSet *src); diff --git a/src/fccharset.c b/src/fccharset.c index 9228b09..14e4c3c 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -262,6 +262,23 @@ FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4) return FcTrue; } +FcBool +FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4) +{ + FcCharLeaf *leaf; + FcChar32 *b; + + if (fcs->ref == FC_REF_CONSTANT) + return FcFalse; + leaf = FcCharSetFindLeaf (fcs, ucs4); + if (!leaf) + return FcTrue; + b = &leaf->map[(ucs4 & 0xff) >> 5]; + *b &= ~(1 << (ucs4 & 0x1f)); + /* We don't bother removing the leaf if it's empty */ + return FcTrue; +} + /* * An iterator for the leaves of a charset */