From d62b85af21777582ad720efd9c319fde97b67d82 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 13 Feb 2009 16:30:43 -0800 Subject: [PATCH] [fclang] Implement FcLangSetGetLangs() (#18846) --- doc/fclangset.fncs | 8 ++++++++ fontconfig/fontconfig.h | 3 +++ src/fclang.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/doc/fclangset.fncs b/doc/fclangset.fncs index 3f69f0d..f9d578e 100644 --- a/doc/fclangset.fncs +++ b/doc/fclangset.fncs @@ -123,6 +123,14 @@ function returns FcLangDiffentTerritory. If ls has no matching language, this function returns FcLangDifferentLang. @@ +@RET@ FcStrSet * +@FUNC@ FcLangSetGetLangs +@TYPE1@ const FcLangSet * @ARG1@ ls +@PURPOSE@ get the list of languages in the langset +@DESC@ +Returns a string set of all languages in langset. +@@ + @RET@ FcStrSet * @FUNC@ FcGetLangs @TYPE1@ void diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 99e2f04..54dedac 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -597,6 +597,9 @@ FcLangSetEqual (const FcLangSet *lsa, const FcLangSet *lsb); FcPublic FcChar32 FcLangSetHash (const FcLangSet *ls); +FcPublic FcStrSet * +FcLangSetGetLangs (const FcLangSet *ls); + /* fclist.c */ FcPublic FcObjectSet * FcObjectSetCreate (void); diff --git a/src/fclang.c b/src/fclang.c index 2553336..d5afd52 100644 --- a/src/fclang.c +++ b/src/fclang.c @@ -744,6 +744,38 @@ FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l) *l_serialize = *l; return l_serialize; } + +FcStrSet * +FcLangSetGetLangs (const FcLangSet *ls) +{ + FcStrSet *langs; + int i; + + langs = FcStrSetCreate(); + if (!langs) + return 0; + + for (i = 0; i < NUM_LANG_CHAR_SET; i++) + if (FcLangSetBitGet (ls, i)) + FcStrSetAdd (langs, fcLangCharSets[i].lang); + + if (ls->extra) + { + FcStrList *list = FcStrListCreate (ls->extra); + FcChar8 *extra; + + if (list) + { + while ((extra = FcStrListNext (list))) + FcStrSetAdd (langs, extra); + + FcStrListDone (list); + } + } + + return langs; +} + #define __fclang__ #include "fcaliastail.h" #include "fcftaliastail.h" -- 2.39.5