示例#1
0
def get_opentype_script_tags(fontfile):
    scripts = []
    dirname = os.path.split(os.path.dirname(fontfile))[1]
    isoscripts = dirname[1:-1].split('__')
    for isoscript in isoscripts:
        scripts += ot_tags_from_script(isoscript)
    if not len(scripts):
        fontfile = os.path.basename(fontfile)
        if fontfile.startswith('NotoSans-'):
            fontfile = fontfile[8:]
        fontfile = fontfile[:fontfile.index('-')]
        scripts = [SCRIPT_TO_OPENTYPE_SCRIPT_TAG.get(fontfile, 'DFLT')]
    return scripts
示例#2
0
def test_ot_tags_from_script():
    # simple
    assert unicodedata.ot_tags_from_script("Latn") == ["latn"]
    # script mapped to multiple new and old script tags
    assert unicodedata.ot_tags_from_script("Deva") == ["dev2", "deva"]
    # exceptions
    assert unicodedata.ot_tags_from_script("Hira") == ["kana"]
    # special script codes map to DFLT
    assert unicodedata.ot_tags_from_script("Zinh") == ["DFLT"]
    assert unicodedata.ot_tags_from_script("Zyyy") == ["DFLT"]
    assert unicodedata.ot_tags_from_script("Zzzz") == ["DFLT"]
    # this is invalid or unknown
    assert unicodedata.ot_tags_from_script("Aaaa") == ["DFLT"]
示例#3
0
def test_ot_tags_from_script():
    # simple
    assert unicodedata.ot_tags_from_script("Latn") == ["latn"]
    # script mapped to multiple new and old script tags
    assert unicodedata.ot_tags_from_script("Deva") == ["dev2", "deva"]
    # exceptions
    assert unicodedata.ot_tags_from_script("Hira") == ["kana"]
    # special script codes map to DFLT
    assert unicodedata.ot_tags_from_script("Zinh") == ["DFLT"]
    assert unicodedata.ot_tags_from_script("Zyyy") == ["DFLT"]
    assert unicodedata.ot_tags_from_script("Zzzz") == ["DFLT"]
    # this is invalid or unknown
    assert unicodedata.ot_tags_from_script("Aaaa") == ["DFLT"]