Add English name first into a cache
In some cases, non-English languages might appears first in current order. and when having English name with non-English language ID like Google Noto CJK TC, English name with English language ID will be dropped due to duplicate. This fixes that issue.
This commit is contained in:
parent
a57f22bf6d
commit
2960391699
|
@ -1152,6 +1152,23 @@ typedef struct
|
|||
unsigned int idx;
|
||||
} FcNameMapping;
|
||||
|
||||
static FcBool
|
||||
_is_english(int platform, int language)
|
||||
{
|
||||
FcBool ret = FcFalse;
|
||||
|
||||
switch (platform)
|
||||
{
|
||||
case TT_PLATFORM_MACINTOSH:
|
||||
ret = language == TT_MAC_LANGID_ENGLISH;
|
||||
break;
|
||||
case TT_PLATFORM_MICROSOFT:
|
||||
ret = language == TT_MS_LANGID_ENGLISH_UNITED_STATES;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
name_mapping_cmp (const void *pa, const void *pb)
|
||||
{
|
||||
|
@ -1161,7 +1178,7 @@ name_mapping_cmp (const void *pa, const void *pb)
|
|||
if (a->platform_id != b->platform_id) return (int) a->platform_id - (int) b->platform_id;
|
||||
if (a->name_id != b->name_id) return (int) a->name_id - (int) b->name_id;
|
||||
if (a->encoding_id != b->encoding_id) return (int) a->encoding_id - (int) b->encoding_id;
|
||||
if (a->language_id != b->language_id) return (int) a->language_id - (int) b->language_id;
|
||||
if (a->language_id != b->language_id) return _is_english(a->platform_id, a->language_id) ? -1 : _is_english(b->platform_id, b->language_id) ? 1 : (int) a->language_id - (int) b->language_id;
|
||||
if (a->idx != b->idx) return (int) a->idx - (int) b->idx;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue