Esempio n. 1
0
def test_many_hints_string_bug354():
    # The glyph T@gid002 has 33 hstem hints. This tests a bug where
    # tx defined an array of only 6 operands.
    # This is encountered only when wrinting to a VF CFF2.
    font_path = get_input_path('cff2_vf.otf')
    cff2_path = get_temp_file_path()
    dcf_path = get_temp_file_path()
    runner(CMD + ['-a', '-o', 'cff2', '-f', font_path, cff2_path])
    runner(CMD + ['-a', '-o', 'dcf', '-f', cff2_path, dcf_path])
    expected_path = get_expected_path('cff2_vf.dcf.txt')
    assert differ([expected_path, dcf_path])
Esempio n. 2
0
def test_subroutine_sorting_bug494():
    """ The input file was made with the command:
    tx -t1 -g 0-5 \
        source-serif-pro/Roman/Instances/Regular/font.ufo bug494.pfa
    The bug is that two subroutines in the Windows CFF output are swapped in
    index order from the Mac version. This was because of an unstable
    'qsort' done on the subroutines in the final stage of selection."""
    font_path = get_input_path('bug494.pfa')
    cff_path = get_temp_file_path()
    dcf_path = get_temp_file_path()
    runner(CMD + ['-a', '-o', 'cff', '*S', 'std', '*b',
                  '-f', font_path, cff_path])
    runner(CMD + ['-a', '-o', 'dcf', '-f', cff_path, dcf_path])
    expected_path = get_expected_path('bug494.dcf.txt')
    assert differ([expected_path, dcf_path])
def test_componentize():
    ttf_path = _get_test_ttf_path()
    save_path = get_temp_file_path()
    opts = Object()
    setattr(opts, 'font_path', ttf_path)
    setattr(opts, 'output_path', save_path)
    ufo, ps_names = ttfcomp.get_glyph_names_mapping(_get_test_ufo_path())
    ttcomp_obj = ttfcomp.TTComponentizer(ufo, ps_names, opts)
    ttcomp_obj.componentize()

    # 'get_composites_data' method
    comps_data = ttcomp_obj.composites_data
    comps_name_list = sorted(comps_data.keys())
    comps_comp_list = [comps_data[gname] for gname in comps_name_list]
    assert comps_name_list == ['aa', 'aacute', 'adieresis', 'atilde',
                               'uni01CE']
    assert comps_comp_list[1].names == ('a', 'uni0301')
    assert comps_comp_list[4].names == ('a', 'uni030C')
    assert comps_comp_list[1].positions == ((0, 0), (263.35, 0))
    assert comps_comp_list[4].positions == ((0, 0), (263, 0))

    # 'assemble_components' method
    comps_data = ttfcomp.ComponentsData()
    comps_data.names = ('a', 'uni01CE')
    comps_data.positions = ((0, 0), (263, 0))
    comps_data.same_advwidth = True
    comp_one, comp_two = ttcomp_obj.assemble_components(comps_data)
    assert comp_one.glyphName == 'a'
    assert comp_two.glyphName == 'uni01CE'
    assert (comp_one.x, comp_one.y) == (0, 0)
    assert (comp_two.x, comp_two.y) == (263, 0)
    assert comp_one.flags == 0x204
    assert comp_two.flags == 0x4
Esempio n. 4
0
def test_font_with_outdated_hash_bug239():
    input_path = get_input_path('bug239/font_outdated_hash.ufo')
    output_path = get_temp_file_path()
    with pytest.raises(subprocess.CalledProcessError) as err:
        runner(CMD + ['-o', 'f', '_{}'.format(input_path),
                            'o', '_{}'.format(output_path)])
    assert err.value.returncode == 1
Esempio n. 5
0
def test_beztools_hhint_over_limit_bug629():
    test_filename = 'bug629.pfa'
    actual_path = get_temp_file_path()
    expected_path = get_expected_path(test_filename)
    runner(CMD +
           ['-o', 'nb', 'o', '_{}'.format(actual_path), '-f', test_filename])
    assert differ([expected_path, actual_path])
def test_report2():
    input_dir = get_input_path('font-family')
    expected_path = get_expected_path('font-family.txt')
    log_path = get_temp_file_path()
    runner(CMD + ['-o', 'd', '_{}'.format(input_dir),
                  'rm', 'rn', 'rp', 'l', '_{}'.format(log_path)])
    assert differ([expected_path, log_path, '-l', '1'])
Esempio n. 7
0
def test_build_options_cs_cl_bug459(args, input_filename, ttx_filename):
    actual_path = get_temp_file_path()
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'o', '_{}'.format(actual_path)] + args)
    actual_ttx = generate_ttx_dump(actual_path, ['cmap'])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 8
0
def test_font_with_hash_bug239():
    input_path = get_input_path('bug239/font.ufo')
    output_path = get_temp_file_path()
    runner(
        CMD +
        ['-o', 'f', '_{}'.format(input_path), 'o', '_{}'.format(output_path)])
    assert font_has_table(output_path, 'CFF ')
Esempio n. 9
0
def test_cff2_extract(args, exp_filename):
    # read CFF2 VF, write CFF2 table
    font_path = get_input_path('SourceCodeVariable-Roman.otf')
    cff2_path = get_temp_file_path()
    runner(CMD + ['-a', '-f', font_path, cff2_path, '-o', 'cff2'] + args)
    expected_path = get_expected_path(exp_filename)
    assert differ([expected_path, cff2_path, '-m', 'bin'])
Esempio n. 10
0
def test_recalculate_font_bbox_bug618(to_format, args, exp_filename):
    font_path = get_input_path('bug618.pfa')
    save_path = get_temp_file_path()

    runner(CMD + ['-f', font_path, save_path, '-o', to_format] + args)

    file_ext = to_format
    if to_format == 't1':
        file_ext = 'pfa'
    elif to_format == 'afm':
        file_ext = 'txt'

    expected_path = get_expected_path(
        'bug618/{}.{}'.format(exp_filename, file_ext))

    diff_mode = []
    if to_format == 'cff':
        diff_mode = ['-m', 'bin']

    skip = []
    if to_format == 'afm':
        skip = ['-s', 'Comment Creation Date:' + SPLIT_MARKER +
                'Comment Copyright']

    assert differ([expected_path, save_path] + diff_mode + skip)
Esempio n. 11
0
def test_st28_basic_cmap():
    input_dir = get_input_path('basic_cmap')
    expected_path = get_expected_path('st28_basic_cmap.txt')
    log_path = get_temp_file_path()
    runner(CMD + ['-o', 'st', '_28', 'd', '_{}'.format(input_dir),
                  'l', '_{}'.format(log_path)])
    assert differ([expected_path, log_path, '-l', '1'])
def test_run_cli_with_output_path():
    actual_path = get_temp_file_path()
    runner(CMD + ['-o', 'o', '_{}'.format(actual_path),
                  '_{}'.format(get_input_path(TEST_TTF_FILENAME))])
    actual_ttx = generate_ttx_dump(actual_path, ['maxp', 'glyf'])
    expected_ttx = get_expected_path('ttfcomponentizer.ttx')
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 13
0
def test_skip_ufo3_global_guides_bug700():
    input_filename = "bug700/font.ufo"
    actual_path = get_temp_file_path()
    runner(CMD + [
        '-o', 'f', '_{}'.format(get_input_path(input_filename)), 'o',
        '_{}'.format(actual_path)
    ])
    assert font_has_table(actual_path, 'CFF ')
Esempio n. 14
0
def test_beztools_hhint_over_limit_bug629():
    test_filename = 'bug629.pfa'
    actual_path = get_temp_file_path()
    expected_path = get_expected_path(test_filename)
    runner(CMD + ['-o', 'nb', 'o', '_{}'.format(actual_path),
                  '-f', test_filename])
    assert differ([expected_path, actual_path,
                   '-s', r'%%Copyright: Copyright'])
Esempio n. 15
0
def test_report(font_family, font_format):
    input_dir = os.path.join(get_input_path(font_family), font_format)
    log_path = get_temp_file_path()
    runner(CMD + ['-o', 'd', '_{}'.format(input_dir), 'tolerance', '_3',
                  'rm', 'rn', 'rp', 'l', '_{}'.format(log_path)])
    expected_path = get_expected_path('{}_{}.txt'.format(
                                      font_family, font_format))
    assert differ([expected_path, log_path, '-l', '1'])
def test_run_with_output_path():
    ttf_path = _get_test_ttf_path()
    save_path = get_temp_file_path()
    ttfcomp.main(['-o', save_path, ttf_path])
    gtable = TTFont(save_path)['glyf']
    composites = [gname for gname in gtable.glyphs if (
        gtable[gname].isComposite())]
    assert sorted(composites) == ['aa', 'aacute', 'uni01CE']
def test_run_invalid_ufo():
    ttf_path = _get_test_ttf_path()
    temp_dir = tempfile.mkdtemp()
    save_path = get_temp_file_path(directory=temp_dir)
    ufo_path = save_path + '.ufo'
    copy2(ttf_path, save_path)
    copy2(ttf_path, ufo_path)
    assert ttfcomp.main([save_path]) == 1
Esempio n. 18
0
def test_linux_ci_failure_bug570():
    table_path = get_input_path('1_fdict.cff')
    font_path = get_input_path('core.otf')
    actual_path = get_temp_file_path()
    runner(CMD + ['-a', '-o', 'a', '_CFF={}'.format(table_path),
                  '-f', font_path, actual_path])
    expected_path = get_expected_path('1_fdict.otf')
    assert differ([expected_path, actual_path, '-m', 'bin'])
Esempio n. 19
0
def test_cff2_no_vf_bug353():
    # read CFF2 WITHOUT VF info, write a CFF2 out. 'regular_CFF2.otf'
    # is derived by taking the regular.otf file from the sfntdiff
    # 'input_data' directory, and converting the CFF table to CFF2.
    font_path = get_input_path('regular_CFF2.otf')
    cff2_path = get_temp_file_path()
    runner(CMD + ['-a', '-o', 'cff2', '-f', font_path, cff2_path])
    expected_path = get_expected_path('regular_CFF2.cff2')
    assert differ([expected_path, cff2_path, '-m', 'bin'])
Esempio n. 20
0
def test_missing_table_extract_bug160():
    actual_path = get_temp_file_path()
    stderr_path = runner(CMD + ['-s', '-e', '-f', LIGHT, actual_path, '-o',
                                'x', '_xyz,head={}'.format(actual_path)])
    with open(stderr_path, 'rb') as f:
        output = f.read()
    assert b'[WARNING]: table missing (xyz )' in output
    expected_path = get_expected_path('head_light.tb')
    assert differ([expected_path, actual_path, '-m', 'bin'])
Esempio n. 21
0
def test_missing_table_delete_bug160():
    actual_path = get_temp_file_path()
    stderr_path = runner(CMD + ['-s', '-e', '-o', 'd', '_xyz,GSUB',
                                '-f', LIGHT, actual_path])
    with open(stderr_path, 'rb') as f:
        output = f.read()
    assert b'[WARNING]: table missing (xyz )' in output
    assert font_has_table(get_input_path(LIGHT), 'GSUB')
    assert not font_has_table(actual_path, 'GSUB')
Esempio n. 22
0
def test_linux_ci_failure_bug570():
    table_path = get_input_path('1_fdict.cff')
    font_path = get_input_path('core.otf')
    actual_path = get_temp_file_path()
    runner(
        CMD +
        ['-a', '-o', 'a', f'_CFF={table_path}', '-f', font_path, actual_path])
    expected_path = get_expected_path('1_fdict.otf')
    assert differ([expected_path, actual_path, '-m', 'bin'])
Esempio n. 23
0
def test_missing_table_delete_bug160():
    actual_path = get_temp_file_path()
    stderr_path = runner(
        CMD + ['-s', '-e', '-o', 'd', '_xyz,GSUB', '-f', LIGHT, actual_path])
    with open(stderr_path, 'rb') as f:
        output = f.read()
    assert b'[WARNING]: table missing (xyz )' in output
    assert font_has_table(get_input_path(LIGHT), 'GSUB')
    assert not font_has_table(actual_path, 'GSUB')
Esempio n. 24
0
def test_seac_in_charstring_bug125(tool_name):
    pdf_filename = f'bug125_{tool_name}.pdf'
    font_path = get_input_path('seac.otf')
    save_path = get_temp_file_path()
    runner(['-t', tool_name, '-o', 'o', f'_{save_path}', 'dno',
            '=pageIncludeTitle', '_0', '-f', font_path, '-a'])
    expected_path = get_expected_path(pdf_filename)
    assert differ([expected_path, save_path,
                   '-s', '/CreationDate', '-e', 'macroman'])
Esempio n. 25
0
def test_outline_from_processed_layer_bug703():
    input_filename = 'bug703.ufo'
    ttx_filename = 'bug703.ttx'
    actual_path = get_temp_file_path()
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'o', '_{}'.format(actual_path)])
    actual_ttx = generate_ttx_dump(actual_path, ['CFF '])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 26
0
def test_run_cli_with_output_path():
    actual_path = get_temp_file_path()
    runner(CMD + [
        '-o', 'o', '_{}'.format(actual_path), '_{}'.format(
            get_input_path(TEST_TTF_FILENAME))
    ])
    actual_ttx = generate_ttx_dump(actual_path, ['maxp', 'glyf'])
    expected_ttx = get_expected_path('ttfcomponentizer.ttx')
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 27
0
def test_convert(otf_filenames, ttc_filename, tables_msg):
    actual_path = get_temp_file_path()
    expected_path = get_expected_path(ttc_filename)
    stdout_path = runner(CMD + ['-s', '-o', 'o', '_{}'.format(actual_path),
                                '-f'] + otf_filenames)
    with open(stdout_path, 'rb') as f:
        output = f.read()
    assert tables_msg in output
    assert differ([expected_path, actual_path, '-m', 'bin'])
Esempio n. 28
0
def test_feature_includes_ufo_bug164():
    input_filename = "bug164/d1/d2/font.ufo"
    otf_path = get_temp_file_path()

    runner(CMD + ['-o',
                  'f', '_{}'.format(get_input_path(input_filename)),
                  'o', '_{}'.format(otf_path)])

    assert font_has_table(otf_path, 'head')
Esempio n. 29
0
def test_fontsetplot_ttf_with_components_bug1125():
    pdf_filename = "bug1125.pdf"
    font_path = get_input_path('bug1125.ttf')
    save_path = get_temp_file_path()
    runner(['-t', 'fontsetplot', '-o', 'o', f'_{save_path}', 'dno',
            '=pageIncludeTitle', '_0', f'_{font_path}'])
    expected_path = get_expected_path(pdf_filename)

    assert(differ([expected_path, save_path,
                   '-s', '/CreationDate', '-e', 'macroman']))
Esempio n. 30
0
def test_round_glyph_bounds_values_bug128(font_format):
    bug_numb = 'bug128'
    pdf_filename = f'{bug_numb}_{font_format}.pdf'
    font_path = get_input_path(f'{bug_numb}/font.{font_format}')
    save_path = get_temp_file_path()
    runner(['-t', 'charplot', '-o', 'o', f'_{save_path}', 'g', '_o',
            'dno', '=pageIncludeTitle', '_0', '-f', font_path, '-a'])
    expected_path = get_expected_path(pdf_filename)
    assert differ([expected_path, save_path,
                   '-s', '/CreationDate', '-e', 'macroman'])
Esempio n. 31
0
def test_t_option():
    actual_path = get_temp_file_path()
    expected_path = get_expected_path('shared_glyf.ttc')
    stdout_path = runner(CMD + [
        '-s', '-o', 'o', f'_{actual_path}', 't', '_glyf=0', '-f', FONT0, FONT1
    ])
    with open(stdout_path, 'rb') as f:
        output = f.read()
    assert MSG_5 in output
    assert differ([expected_path, actual_path, '-m', 'bin'])
Esempio n. 32
0
def test_GDEF_LigatureCaret_bug155(caret_format):
    input_filename = 'bug155/font.pfa'
    feat_filename = 'bug155/caret-{}.fea'.format(caret_format)
    ttx_filename = 'bug155/caret-{}.ttx'.format(caret_format)
    actual_path = get_temp_file_path()
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'ff', '_{}'.format(get_input_path(feat_filename)),
                        'o', '_{}'.format(actual_path)])
    actual_ttx = generate_ttx_dump(actual_path, ['GDEF'])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-l', '2'])
Esempio n. 33
0
def test_cs_opt_bug684(filename):
    """ The input CFF2 variable font contains a long single charstring
    making the maximum use of the operand stack.
    tx was generating a bad CFF2 charstring that would overflow
    the operand stack of the standard size (513) after re-converted
    to CFF2 unless -no_opt option is specified."""
    font_path = get_input_path('{}.otf'.format(filename))
    result_path = get_temp_file_path()
    expected_path = get_expected_path('{}.cff2'.format(filename))
    runner(CMD + ['-a', '-o', 'cff2', '-f', font_path, result_path])
    assert differ([expected_path, result_path, '-m', 'bin'])
Esempio n. 34
0
def test_contextual_multiple_substitutions_bug725():
    input_filename = "bug725/font.pfa"
    feat_filename = "bug725/feat.fea"
    actual_path = get_temp_file_path()
    ttx_filename = "bug725.ttx"
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'ff', '_{}'.format(get_input_path(feat_filename)),
                        'o', '_{}'.format(actual_path)])
    actual_ttx = generate_ttx_dump(actual_path, ['GSUB'])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 35
0
def test_long_charstring_write():
    # read a CFF2 VF with a charstring longer that 65535, write out CFF2 file
    # NOTE: the font 'CJK-VarTest.otf' cannot be used in this test because
    # once its long charstring is optimized (floats -> ints) it's no longer
    # over the 65535 bytes limit; the long charstring in 'CJK-VarTest2.otf' is
    # already as small as possible, so it will trigger the check in cffwrite.c
    font_path = get_input_path('CJK-VarTest2.otf')
    cff2_path = get_temp_file_path()
    runner(CMD + ['-a', '-o', 'cff2', '-f', font_path, cff2_path])
    expected_path = get_expected_path('CJK-VarTest2.cff2')
    assert differ([expected_path, cff2_path, '-m', 'bin'])
Esempio n. 36
0
def test_useMarkFilteringSet_flag_bug196():
    input_filename = "bug196/font.pfa"
    feat_filename = "bug196/feat.fea"
    actual_path = get_temp_file_path()
    ttx_filename = "bug196.ttx"
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'ff', '_{}'.format(get_input_path(feat_filename)),
                        'o', '_{}'.format(actual_path)])
    actual_ttx = generate_ttx_dump(actual_path, ['GSUB'])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 37
0
def test_useException_bug321():
    input_filename = "bug321/font.pfa"
    feat_filename = "bug321/feat.fea"
    actual_path = get_temp_file_path()
    ttx_filename = "bug321.ttx"
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'ff', '_{}'.format(get_input_path(feat_filename)),
                        'o', '_{}'.format(actual_path)])
    actual_ttx = generate_ttx_dump(actual_path, ['GSUB', 'GPOS'])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 38
0
def test_mark_refer_diff_classes_bug416():
    input_filename = "bug416/font.pfa"
    feat_filename = "bug416/feat.fea"
    actual_path = get_temp_file_path()
    ttx_filename = "bug416.ttx"
    runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)),
                        'ff', '_{}'.format(get_input_path(feat_filename)),
                        'o', '_{}'.format(actual_path)])
    actual_ttx = generate_ttx_dump(actual_path, ['GPOS'])
    expected_ttx = get_expected_path(ttx_filename)
    assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
Esempio n. 39
0
def test_duplicate_warning_messages_bug751():
    input_filename = 'bug751.ufo'
    expected_path = get_expected_path('bug751.txt')
    otf_path = get_temp_file_path()

    stderr_path = runner(
        CMD + ['-s', '-e', '-o',
               'f', '_{}'.format(get_input_path(input_filename)),
               'o', '_{}'.format(otf_path)])

    assert differ([expected_path, stderr_path, '-l', '1',
                   '-s', 'Built development mode font'])
Esempio n. 40
0
def test_non_varying_glyphs_bug356():
    """A glyph which is non-varying in a variable font may be referenced by a
    VariationStore data item subtable which has a region count of 0. The VF
    support code assumed that this was an error, and issued a false warning.
    File 'bug356.otf' is a handcrafted modification of 'cff2_vf.otf'. The
    latter cannot be used as-is to validate the fix."""
    actual_path = get_temp_file_path()
    font_path = get_input_path('bug356.otf')
    stderr_path = runner(CMD + ['-s', '-e', '-a', '-o', 'cff',
                                '-f', font_path, actual_path])
    expected_path = get_expected_path('bug356.txt')
    assert differ([expected_path, stderr_path, '-l', '1'])