]> git.wh0rd.org - fontconfig.git/blobdiff - src/fclang.c
Fix bug 2878 (excessive relocations at startup for charsets, reported by
[fontconfig.git] / src / fclang.c
index a10641edf953c89586dc9aa03f87879b1712384a..b1c7c3ff80b294e31ac08f5288924509c7365329 100644 (file)
@@ -44,6 +44,8 @@ struct _FcLangSet {
 #define FcLangSetBitSet(ls, id)        ((ls)->map[(id)>>5] |= ((FcChar32) 1 << ((id) & 0x1f)))
 #define FcLangSetBitGet(ls, id) (((ls)->map[(id)>>5] >> ((id) & 0x1f)) & 1)
 
+static FcBool langsets_populated = FcFalse;
+
 FcLangSet *
 FcFreeTypeLangSet (const FcCharSet  *charset, 
                   const FcChar8    *exclusiveLang)
@@ -52,7 +54,12 @@ FcFreeTypeLangSet (const FcCharSet  *charset,
     FcChar32       missing;
     const FcCharSet *exclusiveCharset = 0;
     FcLangSet      *ls;
-    
+
+    if (!langsets_populated)
+    {
+        FcLangCharSetPopulate ();
+        langsets_populated = FcTrue;
+    }
 
     if (exclusiveLang)
        exclusiveCharset = FcCharSetForLang (exclusiveLang);
@@ -188,6 +195,13 @@ FcCharSetForLang (const FcChar8 *lang)
 {
     int                i;
     int                country = -1;
+
+    if (!langsets_populated)
+    {
+        FcLangCharSetPopulate ();
+        langsets_populated = FcTrue;
+    }
+
     for (i = 0; i < NUM_LANG_CHAR_SET; i++)
     {
        switch (FcLangCompare (lang, fcLangCharSets[i].lang)) {