Esempio n. 1
0
def test_default_run_ubuntu():
    """This is used to test VDMX table removal"""
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Ubuntu-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Ubuntu-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Ubuntu-Regular-dehinted.ttf")
    test_args = [test_inpath]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    font_validator(test_outpath)

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 2
0
def test_run_roboto_keep_head():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Roboto-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Roboto-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Roboto-Regular-dehinted.ttf")
    test_args = [test_inpath, "--keep-head"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    tt = TTFont(test_outpath)
    assert (tt["head"].flags & 1 << 4) != 0

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 3
0
def test_run_roboto_keep_gasp():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Roboto-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Roboto-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Roboto-Regular-dehinted.ttf")
    test_args = [test_inpath, "--keep-gasp"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    tt = TTFont(test_outpath)
    assert tt["gasp"].gaspRange == {
        8: 2,
        65535: 15
    }  # unmodified value in Roboto

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 4
0
def test_run_noto_keep_maxp():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "NotoSans-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "NotoSans-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "NotoSans-Regular-dehinted.ttf")
    test_args = [test_inpath, "--keep-maxp"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    tt = TTFont(test_outpath)
    assert tt["maxp"].maxZones != 0
    assert tt["maxp"].maxTwilightPoints != 0
    assert tt["maxp"].maxStorage != 0
    assert tt["maxp"].maxFunctionDefs != 0
    assert tt["maxp"].maxStackElements != 0
    assert tt["maxp"].maxSizeOfInstructions != 0

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 5
0
def test_run_roboto_keep_glyf():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Roboto-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Roboto-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Roboto-Regular-dehinted.ttf")
    test_args = [test_inpath, "--keep-glyf"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    tt_pre = TTFont(test_inpath)
    tt_post = TTFont(test_outpath)
    assert tt_pre["glyf"] == tt_post["glyf"]

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 6
0
def test_default_run_ubuntu_keep_vdmx():
    """This is used to test VDMX table removal"""
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Ubuntu-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Ubuntu-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Ubuntu-Regular-dehinted.ttf")
    test_args = [test_inpath, "--keep-vdmx"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    tt = TTFont(test_outpath)
    assert "VDMX" in tt

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 7
0
def test_run_noto_keep_ttfa(
):  # this has to be tested in Noto as it contains a TTFA table
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "NotoSans-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "NotoSans-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "NotoSans-Regular-dehinted.ttf")
    test_args = [test_inpath, "--keep-ttfa"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    tt = TTFont(test_outpath)
    assert "TTFA" in tt

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 8
0
def test_default_run_opensans_vf_keep_cvar():
    """This is used to test cvar table removal in a var font"""
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "OpenSans-VF.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "OpenSans.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "OpenSans-dehinted.ttf")
    test_args = [test_inpath, "--keep-cvar"]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    font_validator(test_outpath)
    assert "cvar" in TTFont(test_outpath)

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 9
0
def test_default_run_roboto_quiet_flag_stdout_test(capsys):
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Roboto-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Roboto-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Roboto-Regular-dehinted.ttf")
    test_args = ["--quiet", test_inpath]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)
    captured = capsys.readouterr()
    assert captured.out == ""

    # test
    font_validator(test_outpath)

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 10
0
def test_run_dehinted_file_write_inplace():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "NotoSans-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "NotoSans-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "NotoSans-Regular.ttf")
    test_args = [test_inpath, "-o", test_outpath]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    with pytest.raises(SystemExit):
        run(test_args)

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 11
0
def test_default_run_noto():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "NotoSans-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "NotoSans-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "NotoSans-Regular-dehinted.ttf")
    test_args = [test_inpath]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    font_validator(test_outpath)

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 12
0
def test_run_with_outfile_path_roboto():
    test_dir = os.path.join("tests", "test_files", "fonts", "temp")
    notouch_inpath = os.path.join("tests", "test_files", "fonts",
                                  "Roboto-Regular.ttf")
    test_inpath = os.path.join("tests", "test_files", "fonts", "temp",
                               "Roboto-Regular.ttf")
    test_outpath = os.path.join("tests", "test_files", "fonts", "temp",
                                "Roboto-Regular-dehintilio.ttf")
    test_args = [test_inpath, "--out", test_outpath]

    # setup
    if os.path.isdir(test_dir):
        shutil.rmtree(test_dir)
    os.mkdir(test_dir)
    shutil.copyfile(notouch_inpath, test_inpath)

    # execute
    run(test_args)

    # test
    font_validator(test_outpath)

    # tear down
    shutil.rmtree(test_dir)
Esempio n. 13
0
def test_run_with_non_font_file():
    with pytest.raises(SystemExit):
        run([os.path.join("tests", "test_files", "text", "test.txt")])
Esempio n. 14
0
def test_run_with_invalid_filepath():
    with pytest.raises(SystemExit):
        run(["bogusfile.txt"])