Pass through unknown ISO 639-3 language tags to OpenType engine

In hb_ot_tag_from_language(), if first component of an unknown
language is three letters long, use it directly as OpenType language
tag (after case conversion and padding).
This commit is contained in:
Behdad Esfahbod 2011-09-02 13:31:19 -04:00
parent ea02cbf03c
commit 738d096a06
2 changed files with 13 additions and 0 deletions

View File

@ -651,6 +651,14 @@ hb_ot_tag_from_language (hb_language_t language)
return HB_TAG('Z','H','S',' '); return HB_TAG('Z','H','S',' ');
} }
s = strchr (lang_str, '-');
if (!s)
s = lang_str + strlen (lang_str);
if (s - lang_str == 3) {
/* Assume it's ISO-639-3 and upper-case and use it. */
return hb_tag_from_string (lang_str, s - lang_str) & ~0x20202000;
}
return HB_OT_TAG_DEFAULT_LANGUAGE; return HB_OT_TAG_DEFAULT_LANGUAGE;
} }

View File

@ -213,12 +213,17 @@ test_ot_tag_language (void)
test_tag_from_language ("dflt", "asdf-asdf-wer-x-hbot-zxc"); test_tag_from_language ("dflt", "asdf-asdf-wer-x-hbot-zxc");
test_tag_from_language ("dflt", "xy");
test_tag_from_language ("XYZ", "xyz"); /* Unknown ISO 639-3 */
test_tag_from_language ("XYZ", "xyz-qw"); /* Unknown ISO 639-3 */
/* Test that x-hbot overrides the base language */ /* Test that x-hbot overrides the base language */
test_tag_from_language ("ABC", "fa-x-hbotabc-zxc"); test_tag_from_language ("ABC", "fa-x-hbotabc-zxc");
test_tag_from_language ("ABC", "fa-ir-x-hbotabc-zxc"); test_tag_from_language ("ABC", "fa-ir-x-hbotabc-zxc");
test_tag_from_language ("ABC", "zh-x-hbotabc-zxc"); test_tag_from_language ("ABC", "zh-x-hbotabc-zxc");
test_tag_from_language ("ABC", "zh-cn-x-hbotabc-zxc"); test_tag_from_language ("ABC", "zh-cn-x-hbotabc-zxc");
test_tag_from_language ("ABC", "zh-xy-x-hbotabc-zxc"); test_tag_from_language ("ABC", "zh-xy-x-hbotabc-zxc");
test_tag_from_language ("ABC", "xyz-xy-x-hbotabc-zxc");
} }
int int