예제 #1
0
def test_fontline_commandline_longusage(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', '--usage']
        main()
        out, err = capsys.readouterr()
        assert out.endswith("Usage: font-line [subcommand] <arg> [font path 1] <font path 2> <font path ...>") is True
예제 #2
0
def test_percent_cmd_percent_arg_less_zero(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'percent', '-1', 'Test.ttf']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Please enter a percent value that is greater than zero."
예제 #3
0
def test_percent_cmd_font_file_wrong_filetype(capsys):
    from fontline.app import main
    testfile_path = os.path.join("tests", "testingfiles", "bogus.txt")
    sys.argv = ['font-line', 'percent', '20', testfile_path]
    main()
    out, err = capsys.readouterr()
    assert ("does not appear to be a supported font file type." in err) is True
예제 #4
0
def test_report_cmd_reportstring_capheight(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[OS/2] CapHeight:      1493" in out
예제 #5
0
def test_report_cmd_reportstring_typodescender(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[OS/2] TypoDescender: \t-492" in out
예제 #6
0
def test_report_cmd_reportstring_winascent(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[OS/2] WinAscent: \t1901" in out
예제 #7
0
def test_report_cmd_reportstring_sha1(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "SHA1: 638f033cc1b6a21597359278bee62cf7e96557ff" in out
예제 #8
0
def test_report_cmd_reportstring_upm(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[head] Units per Em: \t2048" in out
예제 #9
0
def test_percent_cmd_too_few_args_two(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'percent', '10']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Not enough arguments."
예제 #10
0
def test_report_cmd_reportstring_version(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "Version 2.020;DEV-03192016;" in out
예제 #11
0
def test_report_cmd_reportstring_hhea_to_upm(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "(hhea Asc + Desc) / UPM: \t\t1.16" in out
예제 #12
0
def test_percent_cmd_percent_arg_less_zero(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'percent', '-1', 'Test.ttf']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Please enter a percent value that is greater than zero."
예제 #13
0
def test_report_cmd_reportstring_ascent_descent(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[hhea] Ascent to Descent: \t\t2384" in out
예제 #14
0
def test_report_cmd_reportstring_ascent_typoasc(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "Ascent to TypoAscender: \t345" in out
예제 #15
0
def test_report_cmd_too_few_args(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'report']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Missing file path argument(s) after the report subcommand."
예제 #16
0
def test_report_cmd_reportstring_linegap(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[hhea] LineGap: \t0" in out
예제 #17
0
def test_fontline_commandline_bad_subcmd(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'bogus']
        main()
        out, err = capsys.readouterr()
        assert err.startswith("[font-lines] ERROR: You used an unsupported") is True
예제 #18
0
def test_report_cmd_reportstring_sha1(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "SHA1: 638f033cc1b6a21597359278bee62cf7e96557ff" in out
예제 #19
0
def test_report_cmd_unsupported_filetype(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'bogus.txt')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert err.startswith("[font-line] ERROR: ")
예제 #20
0
def test_percent_cmd_too_few_args_two(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'percent', '10']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Not enough arguments."
예제 #21
0
def test_report_cmd_reportstring_ymin(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[head] yMin:          -573" in out
예제 #22
0
def test_report_cmd_reportstring_version(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "Version 2.020;DEV-03192016;" in out
예제 #23
0
def test_report_cmd_unsupported_filetype(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'bogus.txt')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert err.startswith("[font-line] ERROR: ")
예제 #24
0
def test_percent_cmd_percent_arg_not_integer(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'percent', 'astring', 'Test.ttf']
        main()
        out, err = capsys.readouterr()
        assert err.startswith("[font-line] ERROR: You entered ") is True
예제 #25
0
def test_report_cmd_reportstring_hhea_to_upm(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "hhea metrics / UPM:  1.16" in out
예제 #26
0
def test_report_cmd_reportstring_fsselection_bit7_set_false(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[OS/2] fsSelection USE_TYPO_METRICS bit set: False" in out
예제 #27
0
def test_report_cmd_reportstring_descent_typodesc(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[hhea] Descent to [OS/2] TypoDescender:     -9" in out
예제 #28
0
def test_percent_cmd_percent_arg_not_integer(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'percent', 'astring', 'Test.ttf']
        main()
        out, err = capsys.readouterr()
        assert err.startswith("[font-line] ERROR: You entered ") is True
예제 #29
0
def test_report_cmd_reportstring_typolinegap(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[OS/2] TypoLineGap:    410" in out
예제 #30
0
def test_report_cmd_reportstring_ascent_descent(capsys):
    from fontline.app import main
    filepath = os.path.join('tests', 'testingfiles', 'Hack-Regular.ttf')
    sys.argv = ['font-line', 'report', filepath]
    main()
    out, err = capsys.readouterr()
    assert "[hhea] Ascent to Descent:              2384" in out
예제 #31
0
def test_report_cmd_too_few_args(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', 'report']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Missing file path argument(s) after the report subcommand."
예제 #32
0
def test_percent_cmd_font_file_wrong_filetype(capsys):
    from fontline.app import main
    testfile_path = os.path.join("tests", "testingfiles", "bogus.txt")
    sys.argv = ['font-line', 'percent', '20', testfile_path]
    main()
    out, err = capsys.readouterr()
    assert ("does not appear to be a supported font file type." in err) is True
예제 #33
0
def test_fontline_commandline_notenough_args(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line']
        main()
        out, err = capsys.readouterr()
        assert err == "[font-line] ERROR: Please include one or more arguments with your command."
예제 #34
0
def test_percent_cmd_percent_arg_over_hundred(capsys):
    from fontline.app import main
    sys.argv = ['font-line', 'percent', '200', 'Test.ttf']
    main()
    out, err = capsys.readouterr()
    assert out.startswith(
        "[font-line] Warning: You entered a percent value over 100%.")
예제 #35
0
def test_fontline_commandline_longhelp(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        sys.argv = ['font-line', '--help']
        main()
        out, err = capsys.readouterr()
        assert out.startswith("====================================================") is True
        assert out.endswith("https://github.com/source-foundry/font-line") is True
예제 #36
0
def test_fontline_commandline_longversion(capsys):
    with pytest.raises(SystemExit):
        from fontline.app import main
        from fontline.app import settings
        sys.argv = ['font-line', '--version']
        main()
        out, err = capsys.readouterr()
        assert out == settings.VERSION
예제 #37
0
def test_percent_cmd_ttf_file_30_percent_adobe_approach(capsys):
    try:
        from fontline.app import main
        fontpath = os.path.join('tests', 'testingfiles',
                                'SourceCodePro-Regular.ttf')
        testpath = os.path.join('tests', 'testingfiles',
                                'SourceCodePro-Regular-test.ttf')
        newfont_path = os.path.join(
            'tests', 'testingfiles',
            'SourceCodePro-Regular-test-linegap30.ttf')
        create_test_file(fontpath)
        assert file_exists(testpath) is True
        sys.argv = ['font-line', 'percent', '30', testpath]
        main()

        assert file_exists(newfont_path)

        tt = ttLib.TTFont(newfont_path)

        os2_typo_ascender = tt['OS/2'].sTypoAscender
        os2_typo_descender = tt['OS/2'].sTypoDescender
        os2_win_ascent = tt['OS/2'].usWinAscent
        os2_win_descent = tt['OS/2'].usWinDescent
        os2_typo_linegap = tt['OS/2'].sTypoLineGap
        hhea_ascent = tt['hhea'].ascent
        hhea_descent = tt['hhea'].descent
        hhea_linegap = tt['hhea'].lineGap
        units_per_em = tt['head'].unitsPerEm

        assert os2_typo_ascender == 750
        assert os2_typo_descender == -250
        assert os2_win_ascent == 1005
        assert os2_win_descent == 294
        assert units_per_em == 1000
        assert os2_typo_linegap == 0
        assert hhea_ascent == 1005
        assert hhea_descent == -294
        assert hhea_linegap == 0

        erase_test_file(testpath)
        erase_test_file(newfont_path)
    except Exception as e:
        # cleanup test files
        if file_exists(testpath):
            erase_test_file(testpath)
        if file_exists(newfont_path):
            erase_test_file(newfont_path)
        raise e
예제 #38
0
def test_percent_cmd_otf_file_10_percent_default_approach(capsys):
    try:
        from fontline.app import main
        fontpath = os.path.join('tests', 'testingfiles', 'Hack-Regular.otf')
        testpath = os.path.join('tests', 'testingfiles',
                                'Hack-Regular-test.otf')
        newfont_path = os.path.join('tests', 'testingfiles',
                                    'Hack-Regular-test-linegap10.otf')
        create_test_file(fontpath)
        assert file_exists(testpath) is True
        sys.argv = ['font-line', 'percent', '10', testpath]
        main()

        assert file_exists(newfont_path)

        tt = ttLib.TTFont(newfont_path)

        os2_typo_ascender = tt['OS/2'].sTypoAscender
        os2_typo_descender = tt['OS/2'].sTypoDescender
        os2_win_ascent = tt['OS/2'].usWinAscent
        os2_win_descent = tt['OS/2'].usWinDescent
        os2_typo_linegap = tt['OS/2'].sTypoLineGap
        hhea_ascent = tt['hhea'].ascent
        hhea_descent = tt['hhea'].descent
        hhea_linegap = tt['hhea'].lineGap
        units_per_em = tt['head'].unitsPerEm

        assert os2_typo_ascender == 1556
        assert os2_typo_descender == -492
        assert os2_win_ascent == 1658
        assert os2_win_descent == 594
        assert units_per_em == 2048
        assert os2_typo_linegap == 204
        assert hhea_ascent == 1658
        assert hhea_descent == -594
        assert hhea_linegap == 0

        erase_test_file(testpath)
        erase_test_file(newfont_path)
    except Exception as e:
        # cleanup test files
        if file_exists(testpath):
            erase_test_file(testpath)
        if file_exists(newfont_path):
            erase_test_file(newfont_path)
        raise e
예제 #39
0
def test_percent_cmd_otf_file_10_percent(capsys):
    try:
        from fontline.app import main
        fontpath = os.path.join('tests', 'testingfiles', 'Hack-Regular.otf')
        testpath = os.path.join('tests', 'testingfiles', 'Hack-Regular-test.otf')
        newfont_path = os.path.join('tests', 'testingfiles', 'Hack-Regular-test-linegap10.otf')
        create_test_file(fontpath)
        assert file_exists(testpath) is True
        sys.argv = ['font-line', 'percent', '10', testpath]
        main()

        assert file_exists(newfont_path)

        tt = ttLib.TTFont(newfont_path)

        os2_typo_ascender = tt['OS/2'].__dict__['sTypoAscender']
        os2_typo_descender = tt['OS/2'].__dict__['sTypoDescender']
        os2_win_ascent = tt['OS/2'].__dict__['usWinAscent']
        os2_win_descent = tt['OS/2'].__dict__['usWinDescent']
        os2_typo_linegap = tt['OS/2'].__dict__['sTypoLineGap']
        hhea_ascent = tt['hhea'].__dict__['ascent']
        hhea_descent = tt['hhea'].__dict__['descent']
        hhea_linegap = tt['hhea'].__dict__['lineGap']
        units_per_em = tt['head'].__dict__['unitsPerEm']

        assert os2_typo_ascender == 1556
        assert os2_typo_descender == -492
        assert os2_win_ascent == 1658
        assert os2_win_descent == 594
        assert units_per_em == 2048
        assert os2_typo_linegap == 204
        assert hhea_ascent == 1658
        assert hhea_descent == -594
        assert hhea_linegap == 0

        erase_test_file(testpath)
        erase_test_file(newfont_path)
    except Exception as e:
        # cleanup test files
        if file_exists(testpath):
            erase_test_file(testpath)
        if file_exists(newfont_path):
            erase_test_file(newfont_path)
        raise e
예제 #40
0
def test_percent_cmd_ttf_file_30_percent_adobe_approach(capsys):
    try:
        from fontline.app import main
        fontpath = os.path.join('tests', 'testingfiles', 'SourceCodePro-Regular.ttf')
        testpath = os.path.join('tests', 'testingfiles', 'SourceCodePro-Regular-test.ttf')
        newfont_path = os.path.join('tests', 'testingfiles', 'SourceCodePro-Regular-test-linegap30.ttf')
        create_test_file(fontpath)
        assert file_exists(testpath) is True
        sys.argv = ['font-line', 'percent', '30', testpath]
        main()

        assert file_exists(newfont_path)

        tt = ttLib.TTFont(newfont_path)

        os2_typo_ascender = tt['OS/2'].sTypoAscender
        os2_typo_descender = tt['OS/2'].sTypoDescender
        os2_win_ascent = tt['OS/2'].usWinAscent
        os2_win_descent = tt['OS/2'].usWinDescent
        os2_typo_linegap = tt['OS/2'].sTypoLineGap
        hhea_ascent = tt['hhea'].ascent
        hhea_descent = tt['hhea'].descent
        hhea_linegap = tt['hhea'].lineGap
        units_per_em = tt['head'].unitsPerEm

        assert os2_typo_ascender == 750
        assert os2_typo_descender == -250
        assert os2_win_ascent == 1005
        assert os2_win_descent == 294
        assert units_per_em == 1000
        assert os2_typo_linegap == 0
        assert hhea_ascent == 1005
        assert hhea_descent == -294
        assert hhea_linegap == 0

        erase_test_file(testpath)
        erase_test_file(newfont_path)
    except Exception as e:
        # cleanup test files
        if file_exists(testpath):
            erase_test_file(testpath)
        if file_exists(newfont_path):
            erase_test_file(newfont_path)
        raise e
예제 #41
0
def test_percent_cmd_font_file_missing(capsys):
    from fontline.app import main
    sys.argv = ['font-line', 'percent', '20', 'Test.ttf']
    main()
    out, err = capsys.readouterr()
    assert ("does not appear to be a valid filepath" in err) is True
예제 #42
0
def test_percent_cmd_font_file_missing(capsys):
    from fontline.app import main
    sys.argv = ['font-line', 'percent', '20', 'Test.ttf']
    main()
    out, err = capsys.readouterr()
    assert ("does not appear to be a valid filepath" in err) is True
예제 #43
0
def test_report_cmd_missing_file_request(capsys):
    from fontline.app import main
    sys.argv = ['font-line', 'report', 'missing.txt']
    main()
    out, err = capsys.readouterr()
    assert err.startswith("[font-line] ERROR: ")
예제 #44
0
def test_percent_cmd_percent_arg_over_hundred(capsys):
    from fontline.app import main
    sys.argv = ['font-line', 'percent', '200', 'Test.ttf']
    main()
    out, err = capsys.readouterr()
    assert out.startswith("[font-line] Warning: You entered a percent value over 100%.")
예제 #45
0
def test_report_cmd_missing_file_request(capsys):
    from fontline.app import main
    sys.argv = ['font-line', 'report', 'missing.txt']
    main()
    out, err = capsys.readouterr()
    assert err.startswith("[font-line] ERROR: ")