diff options
author | Sascha Brawer <sascha@brawer.ch> | 2015-06-28 03:29:47 +0200 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2015-09-29 14:32:06 +0100 |
commit | f2ad935e19338a29113492150f0c5a5fd5befd75 (patch) | |
tree | 5d352548d965a8713876a668ee88115454f86e81 | |
parent | b8811429b6810c4f13be087b593a862c17d9d987 (diff) | |
download | harfbuzz-f2ad935e19338a29113492150f0c5a5fd5befd75.tar.gz |
Handle language tags that indicate phonetic IPA transcription
The BCP-47 registry defines a variant subtag "fonipa" that can be used
in combination with arbitrary other language tags. For example,
"rm-CH-fonipa-sursilv" indicates the Sursilvan dialect of Romansh
as used in Switzerland, transcribed used the International Phonetic
Alphabet.
http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
-rw-r--r-- | src/hb-ot-tag.cc | 15 | ||||
-rw-r--r-- | test/api/test-ot-tag.c | 7 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index 37604290..a2e5728f 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -733,7 +733,6 @@ static const LangTag ot_languages[] = { /*{"fuf?", HB_TAG('F','T','A',' ')},*/ /* Futa */ /*{"ar-Syrc?", HB_TAG('G','A','R',' ')},*/ /* Garshuni */ /*{"cfm/rnl?", HB_TAG('H','A','L',' ')},*/ /* Halam */ -/*{"fonipa", HB_TAG('I','P','P','H')},*/ /* Phonetic transcription—IPA conventions */ /*{"ga-Latg?/Latg?", HB_TAG('I','R','T',' ')},*/ /* Irish Traditional */ /*{"krc", HB_TAG('K','A','R',' ')},*/ /* Karachay */ /*{"alw?/ktb?", HB_TAG('K','E','B',' ')},*/ /* Kebena */ @@ -832,6 +831,14 @@ hb_ot_tag_from_language (hb_language_t language) } } + /* + * The International Phonetic Alphabet is a variant tag in BCP-47, + * which can be applied to any language. + */ + if (strstr (lang_str, "-fonipa")) { + return HB_TAG('I','P','P','H'); /* Phonetic transcription—IPA conventions */ + } + /* Find a language matching in the first component */ { const LangTag *lang_tag; @@ -901,6 +908,12 @@ hb_ot_tag_to_language (hb_tag_t tag) } } + /* struct LangTag has only room for 3-letter language tags. */ + switch (tag) { + case HB_TAG('I','P','P','H'): /* Phonetic transcription—IPA conventions */ + return hb_language_from_string ("und-fonipa", -1); + } + /* Else return a custom language in the form of "x-hbotABCD" */ { unsigned char buf[11] = "x-hbot"; diff --git a/test/api/test-ot-tag.c b/test/api/test-ot-tag.c index b667c7d9..29e0aa22 100644 --- a/test/api/test-ot-tag.c +++ b/test/api/test-ot-tag.c @@ -222,6 +222,13 @@ test_ot_tag_language (void) test_tag_from_language ("XYZ", "xyz"); /* Unknown ISO 639-3 */ test_tag_from_language ("XYZ", "xyz-qw"); /* Unknown ISO 639-3 */ + /* International Phonetic Alphabet */ + test_tag_from_language ("IPPH", "en-fonipa"); + test_tag_from_language ("IPPH", "rm-CH-fonipa-sursilv-x-foobar"); + test_tag_from_language ("IPPH", "und-fonipa"); + test_tag_from_language ("IPPH", "zh-fonipa"); + test_tag_to_language ("IPPH", "und-fonipa"); + /* Test that x-hbot overrides the base language */ test_tag_from_language ("ABC", "fa-x-hbotabc-zxc"); test_tag_from_language ("ABC", "fa-ir-x-hbotabc-zxc"); |