summaryrefslogtreecommitdiff
path: root/src/fclang.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2010-12-06 12:38:18 +0900
committerAkira TAGOH <akira@tagoh.org>2010-12-09 11:40:08 +0900
commit3c862aad9f49be4b098cb679a67449c85b58f1f5 (patch)
tree984423e824dbe46ba02cae7bdf6ac2b9b23daf8a /src/fclang.c
parentd975cdda782bb88c8bb6706889a554b2afb9f939 (diff)
downloadfontconfig-3c862aad9f49be4b098cb679a67449c85b58f1f5.tar.gz
Add editing langset feature.
The syntax to add any langset to the langset table looks like: <match target="scan"> <test name="family"> <string>Buggy Sans</string> </test> <edit name="lang" mode="assign"> <plus> <name>lang</name> <langset> <string>zh-cn</string> <string>zh-tw</string> </langset> </plus> </edit> </match> To remove any langset from the langset table: <match target="scan"> <test name="family"> <string>Buggy Sans</string> </test> <edit name="lang" mode="assign"> <minus> <name>lang</name> <langset> <string>ja</string> </langset> </minus> </edit> </match>
Diffstat (limited to 'src/fclang.c')
-rw-r--r--src/fclang.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/fclang.c b/src/fclang.c
index 1c78328..be42b58 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -71,6 +71,20 @@ FcLangSetBitGet (const FcLangSet *ls,
return ((ls->map[bucket] >> (id & 0x1f)) & 1) ? FcTrue : FcFalse;
}
+static void
+FcLangSetBitReset (FcLangSet *ls,
+ unsigned int id)
+{
+ int bucket;
+
+ id = fcLangCharSetIndices[id];
+ bucket = id >> 5;
+ if (bucket >= ls->map_size)
+ return; /* shouldn't happen really */
+
+ ls->map[bucket] &= ~((FcChar32) 1 << (id & 0x1f));
+}
+
FcLangSet *
FcFreeTypeLangSet (const FcCharSet *charset,
const FcChar8 *exclusiveLang)
@@ -400,6 +414,23 @@ FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang)
return FcStrSetAdd (ls->extra, lang);
}
+FcBool
+FcLangSetDel (FcLangSet *ls, const FcChar8 *lang)
+{
+ int id;
+
+ id = FcLangSetIndex (lang);
+ if (id >= 0)
+ {
+ FcLangSetBitReset (ls, id);
+ }
+ else if (ls->extra)
+ {
+ FcStrSetDel (ls->extra, lang);
+ }
+ return FcTrue;
+}
+
FcLangResult
FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang)
{
@@ -818,6 +849,37 @@ FcLangSetGetLangs (const FcLangSet *ls)
return langs;
}
+static FcLangSet *
+FcLangSetOperate(const FcLangSet *a,
+ const FcLangSet *b,
+ FcBool (*func) (FcLangSet *ls,
+ const FcChar8 *s))
+{
+ FcLangSet *langset = FcLangSetCopy (a);
+ FcStrList *sl = FcStrListCreate (FcLangSetGetLangs (b));
+ FcChar8 *str;
+
+ while ((str = FcStrListNext (sl)))
+ {
+ func (langset, str);
+ }
+ FcStrListDone (sl);
+
+ return langset;
+}
+
+FcLangSet *
+FcLangSetUnion (const FcLangSet *a, const FcLangSet *b)
+{
+ return FcLangSetOperate(a, b, FcLangSetAdd);
+}
+
+FcLangSet *
+FcLangSetSubtract (const FcLangSet *a, const FcLangSet *b)
+{
+ return FcLangSetOperate(a, b, FcLangSetDel);
+}
+
#define __fclang__
#include "fcaliastail.h"
#include "fcftaliastail.h"