Use locale data set FC_LANG by default. Reorder FcPattern and FcValueList
to match Xft1.
This commit is contained in:
parent
2fcac34973
commit
e709ddfa10
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "fcint.h"
|
||||
#include <locale.h>
|
||||
|
||||
static struct {
|
||||
char *field;
|
||||
|
@ -84,4 +85,56 @@ FcDefaultSubstitute (FcPattern *pattern)
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ typedef enum _FcValueBinding {
|
|||
|
||||
typedef struct _FcValueList {
|
||||
struct _FcValueList *next;
|
||||
FcValueBinding binding;
|
||||
FcValue value;
|
||||
FcValueBinding binding;
|
||||
} FcValueList;
|
||||
|
||||
typedef struct _FcPatternElt {
|
||||
|
@ -100,8 +100,8 @@ typedef struct _FcPatternElt {
|
|||
struct _FcPattern {
|
||||
int num;
|
||||
int size;
|
||||
int ref;
|
||||
FcPatternElt *elts;
|
||||
int ref;
|
||||
};
|
||||
|
||||
typedef enum _FcOp {
|
||||
|
|
Loading…
Reference in New Issue