Merge pull request #2889 from fonttools/unicodedata-Zmth
[unicodedata] map Zmth<->math in ot_tag_{to,from}_script
This commit is contained in:
commit
a1fc9b1efc
@ -22,11 +22,16 @@ SCRIPT_EXCEPTIONS = {
|
||||
"Yiii": "yi ",
|
||||
"Nkoo": "nko ",
|
||||
"Vaii": "vai ",
|
||||
"Zmth": "math",
|
||||
"Zinh": DEFAULT_SCRIPT,
|
||||
"Zyyy": DEFAULT_SCRIPT,
|
||||
"Zzzz": DEFAULT_SCRIPT,
|
||||
}
|
||||
|
||||
SCRIPT_EXCEPTIONS_REVERSED = {
|
||||
"math": "Zmth",
|
||||
}
|
||||
|
||||
NEW_SCRIPT_TAGS = {
|
||||
"Beng": ("bng2",),
|
||||
"Deva": ("dev2",),
|
||||
|
@ -239,15 +239,13 @@ def ot_tags_from_script(script_code):
|
||||
Unicode script code.
|
||||
Return ['DFLT'] script tag for invalid/unknown script codes.
|
||||
"""
|
||||
if script_code in OTTags.SCRIPT_EXCEPTIONS:
|
||||
return [OTTags.SCRIPT_EXCEPTIONS[script_code]]
|
||||
|
||||
if script_code not in Scripts.NAMES:
|
||||
return [OTTags.DEFAULT_SCRIPT]
|
||||
|
||||
script_tags = [
|
||||
OTTags.SCRIPT_EXCEPTIONS.get(
|
||||
script_code,
|
||||
script_code[0].lower() + script_code[1:]
|
||||
)
|
||||
]
|
||||
script_tags = [script_code[0].lower() + script_code[1:]]
|
||||
if script_code in OTTags.NEW_SCRIPT_TAGS:
|
||||
script_tags.extend(OTTags.NEW_SCRIPT_TAGS[script_code])
|
||||
script_tags.reverse() # last in, first out
|
||||
@ -278,6 +276,9 @@ def ot_tag_to_script(tag):
|
||||
if tag in OTTags.NEW_SCRIPT_TAGS_REVERSED:
|
||||
return OTTags.NEW_SCRIPT_TAGS_REVERSED[tag]
|
||||
|
||||
if tag in OTTags.SCRIPT_EXCEPTIONS_REVERSED:
|
||||
return OTTags.SCRIPT_EXCEPTIONS_REVERSED[tag]
|
||||
|
||||
# This side of the conversion is fully algorithmic
|
||||
|
||||
# Any spaces at the end of the tag are replaced by repeating the last
|
||||
|
@ -210,6 +210,7 @@ def test_ot_tags_from_script():
|
||||
assert unicodedata.ot_tags_from_script("Deva") == ["dev2", "deva"]
|
||||
# exceptions
|
||||
assert unicodedata.ot_tags_from_script("Hira") == ["kana"]
|
||||
assert unicodedata.ot_tags_from_script("Zmth") == ["math"]
|
||||
# special script codes map to DFLT
|
||||
assert unicodedata.ot_tags_from_script("Zinh") == ["DFLT"]
|
||||
assert unicodedata.ot_tags_from_script("Zyyy") == ["DFLT"]
|
||||
@ -232,6 +233,7 @@ 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"
|
||||
assert unicodedata.ot_tag_to_script("math") == "Zmth"
|
||||
# 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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user