*/
#include "fcint.h"
+#include <locale.h>
static struct {
char *field;
size *= dpi / 72.0;
FcPatternAddDouble (pattern, FC_PIXEL_SIZE, size);
}
+
+ if (FcPatternGet (pattern, FC_LANG, 0, &v) == FcResultNoMatch)
+ {
+ char *lang;
+ char *territory;
+ char *after;
+ int lang_len, territory_len;
+ char lang_local[128];
+ char *ctype = setlocale (LC_CTYPE, NULL);
+
+ /*
+ * Check if setlocale (LC_ALL, "") has been called
+ */
+ if (!ctype || !strcmp (ctype, "C"))
+ {
+ ctype = getenv ("LC_ALL");
+ if (!ctype)
+ {
+ ctype = getenv ("LC_CTYPE");
+ if (!ctype)
+ ctype = getenv ("LANG");
+ }
+ }
+ if (ctype)
+ {
+ lang = ctype;
+ territory = strchr (ctype, '_');
+ if (territory)
+ {
+ lang_len = territory - lang;
+ territory = territory + 1;
+ after = strchr (territory, '.');
+ if (!after)
+ {
+ after = strchr (territory, '@');
+ if (!after)
+ after = territory + strlen (territory);
+ }
+ territory_len = after - territory;
+ if (lang_len + 1 + territory_len + 1 <= sizeof (lang_local))
+ {
+ strncpy (lang_local, lang, lang_len);
+ lang_local[lang_len] = '-';
+ strncpy (lang_local + lang_len + 1, territory, territory_len);
+ lang_local[lang_len + 1 + territory_len] = '\0';
+ FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang_local);
+ }
+ }
+ else
+ FcPatternAddString (pattern, FC_LANG, (FcChar8 *) lang);
+ }
+ }
}