Merge pull request #2508 from fonttools/jamo-as-hang-ot-script
unicodedata: alias 'jamo' script tag to 'hang'
This commit is contained in:
commit
c50cc3e1eb
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
DEFAULT_SCRIPT = "DFLT"
|
DEFAULT_SCRIPT = "DFLT"
|
||||||
|
|
||||||
|
SCRIPT_ALIASES = {
|
||||||
|
"jamo": "hang",
|
||||||
|
}
|
||||||
|
|
||||||
SCRIPT_EXCEPTIONS = {
|
SCRIPT_EXCEPTIONS = {
|
||||||
"Hira": "kana",
|
"Hira": "kana",
|
||||||
"Hrkt": "kana",
|
"Hrkt": "kana",
|
||||||
|
@ -264,6 +264,9 @@ def ot_tag_to_script(tag):
|
|||||||
if not tag or " " in tag or len(tag) > 4:
|
if not tag or " " in tag or len(tag) > 4:
|
||||||
raise ValueError("invalid OpenType tag: %r" % tag)
|
raise ValueError("invalid OpenType tag: %r" % tag)
|
||||||
|
|
||||||
|
if tag in OTTags.SCRIPT_ALIASES:
|
||||||
|
tag = OTTags.SCRIPT_ALIASES[tag]
|
||||||
|
|
||||||
while len(tag) != 4:
|
while len(tag) != 4:
|
||||||
tag += str(" ") # pad with spaces
|
tag += str(" ") # pad with spaces
|
||||||
|
|
||||||
|
@ -230,6 +230,9 @@ def test_ot_tag_to_script():
|
|||||||
assert unicodedata.ot_tag_to_script("vai ") == "Vaii"
|
assert unicodedata.ot_tag_to_script("vai ") == "Vaii"
|
||||||
assert unicodedata.ot_tag_to_script("lao ") == "Laoo"
|
assert unicodedata.ot_tag_to_script("lao ") == "Laoo"
|
||||||
assert unicodedata.ot_tag_to_script("yi") == "Yiii"
|
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"):
|
for invalid_value in ("", " ", "z zz", "zzzzz"):
|
||||||
with pytest.raises(ValueError, match="invalid OpenType tag"):
|
with pytest.raises(ValueError, match="invalid OpenType tag"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user