Use zh-Hans / zh-Hant when converting OT language tag to hb_language_t

This commit is contained in:
Behdad Esfahbod 2014-07-10 19:22:07 -04:00
parent f381e320df
commit 6334495ac1
2 changed files with 6 additions and 15 deletions

View File

@ -880,18 +880,9 @@ hb_ot_tag_to_language (hb_tag_t tag)
if ((tag & 0xFFFF0000) == 0x5A480000) {
switch (tag) {
case HB_TAG('Z','H','H',' '): return hb_language_from_string ("zh-hk", -1); /* Hong Kong */
default: {
/* Encode the tag... */
unsigned char buf[14] = "zh-x-hbot";
buf[9] = tag >> 24;
buf[10] = (tag >> 16) & 0xFF;
buf[11] = (tag >> 8) & 0xFF;
buf[12] = tag & 0xFF;
if (buf[12] == 0x20)
buf[12] = '\0';
buf[13] = '\0';
return hb_language_from_string ((char *) buf, -1);
}
case HB_TAG('Z','H','S',' '): return hb_language_from_string ("zh-Hans", -1); /* Simplified */
case HB_TAG('Z','H','T',' '): return hb_language_from_string ("zh-Hant", -1); /* Traditional */
default: break; /* Fall through */
}
}

View File

@ -207,9 +207,9 @@ test_ot_tag_language (void)
test_tag_from_language ("ZHS", "zh"); /* Chinese */
test_tag_from_language ("ZHS", "zh-xx");
test_tag_to_language ("ZHS", "zh-x-hbotzhs");
test_tag_to_language ("ZHT", "zh-x-hbotzht");
test_tag_to_language ("ZHP", "zh-x-hbotzhp");
test_tag_to_language ("ZHS", "zh-Hans");
test_tag_to_language ("ZHT", "zh-Hant");
test_tag_to_language ("ZHP", "x-hbotzhp");
test_language_two_way ("ABC", "x-hbotabc");
test_tag_from_language ("ABC", "asdf-asdf-wer-x-hbotabc-zxc");