Merge pull request #2508 from fonttools/jamo-as-hang-ot-script

unicodedata: alias 'jamo' script tag to 'hang'
This commit is contained in:
Cosimo Lupo 2022-01-19 17:34:23 +00:00 committed by GitHub
commit c50cc3e1eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,10 @@
DEFAULT_SCRIPT = "DFLT"
SCRIPT_ALIASES = {
"jamo": "hang",
}
SCRIPT_EXCEPTIONS = {
"Hira": "kana",
"Hrkt": "kana",

View File

@ -264,6 +264,9 @@ def ot_tag_to_script(tag):
if not tag or " " in tag or len(tag) > 4:
raise ValueError("invalid OpenType tag: %r" % tag)
if tag in OTTags.SCRIPT_ALIASES:
tag = OTTags.SCRIPT_ALIASES[tag]
while len(tag) != 4:
tag += str(" ") # pad with spaces

View File

@ -230,6 +230,9 @@ def test_ot_tag_to_script():
assert unicodedata.ot_tag_to_script("vai ") == "Vaii"
assert unicodedata.ot_tag_to_script("lao ") == "Laoo"
assert unicodedata.ot_tag_to_script("yi") == "Yiii"
# both 'hang' and 'jamo' tags map to the Hangul script
assert unicodedata.ot_tag_to_script("hang") == "Hang"
assert unicodedata.ot_tag_to_script("jamo") == "Hang"
for invalid_value in ("", " ", "z zz", "zzzzz"):
with pytest.raises(ValueError, match="invalid OpenType tag"):