aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fcstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fontconfig/src/fcstr.c')
-rw-r--r--fontconfig/src/fcstr.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c
index e372af080..c446bcd8e 100644
--- a/fontconfig/src/fcstr.c
+++ b/fontconfig/src/fcstr.c
@@ -1177,6 +1177,50 @@ FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s)
}
FcBool
+FcStrSetAddLangs (FcStrSet *strs, const char *languages)
+{
+ const char *p = languages, *next;
+ FcChar8 lang[128] = {0}, *normalized_lang;
+ size_t len;
+ FcBool ret = FcFalse;
+
+ if (!languages)
+ return FcFalse;
+
+ while ((next = strchr (p, ':')))
+ {
+ len = next - p;
+ len = FC_MIN (len, 128);
+ strncpy ((char *) lang, p, len);
+ lang[len] = 0;
+ /* ignore an empty item */
+ if (*lang)
+ {
+ normalized_lang = FcLangNormalize ((const FcChar8 *) lang);
+ if (normalized_lang)
+ {
+ FcStrSetAdd (strs, normalized_lang);
+ free (normalized_lang);
+ ret = FcTrue;
+ }
+ }
+ p = next + 1;
+ }
+ if (*p)
+ {
+ normalized_lang = FcLangNormalize ((const FcChar8 *) p);
+ if (normalized_lang)
+ {
+ FcStrSetAdd (strs, normalized_lang);
+ free (normalized_lang);
+ ret = FcTrue;
+ }
+ }
+
+ return ret;
+}
+
+FcBool
FcStrSetDel (FcStrSet *set, const FcChar8 *s)
{
int i;