Commit 29603916 authored by Akira TAGOH's avatar Akira TAGOH

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.
parent a57f22bf
Pipeline #47751 passed with stage
in 5 minutes and 49 seconds
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment