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'])
def test_build_otfs(): ds_path = get_input_path('font.designspace') runner(CMD + ['-o', 'd', f'_{ds_path}']) otf1_path = get_input_path('master0.otf') otf2_path = get_input_path('master1.otf') for otf_path in (otf1_path, otf2_path): assert _compare_results(otf_path) if os.path.exists(otf_path): os.remove(otf_path)
def test_psnames(): runner(CMD + ['-f', 'no_psname-mac_psname-no_name_tb.ttc']) fpath1 = get_input_path('no_psname-mac_psname-no_name_tb-font0.ttf') fpath2 = get_input_path('mac_psname.ttf') fpath3 = get_input_path('no_psname-mac_psname-no_name_tb-font2.ttf') for fpth in (fpath1, fpath2, fpath3): assert os.path.exists(fpth) os.remove(fpth)
def test_feature_includes_type1_bug164(feat_filename): input_filename = "bug164/d1/d2/font.pfa" otf_path = get_temp_file_path() runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) assert font_has_table(otf_path, 'head')
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'])
def test_feature_includes_type1_bug164(feat_filename): input_filename = "bug164/d1/d2/font.pfa" otf_path = get_temp_file_path() runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) assert font_has_table(otf_path, 'head')
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'])
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'])
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'])
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'])
def test_multiple_inputs(): fname1 = 'latincid' fname2 = 'sans' path1 = get_input_path(f'{fname1}.otf') path2 = get_input_path(f'{fname2}.otf') out_dir = get_temp_dir_path() out_path1 = path.join(out_dir, f'{fname1}.ttf') out_path2 = path.join(out_dir, f'{fname2}.ttf') assert all([path.exists(out_path1), path.exists(out_path2)]) is False otf2ttf(['-o', out_dir, path1, path2]) assert all([path.exists(out_path1), path.exists(out_path2)]) is True
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'])
def test_delete_zero_kb_font_on_fail_bug736(): input_filename = 'bug736/font.pfa' feat_filename = 'bug736/feat.fea' out_filename = 'bug736/SourceSans-Test.otf' with pytest.raises(subprocess.CalledProcessError) as err: runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename))]) assert err.value.returncode == 1 assert os.path.exists(get_input_path(out_filename)) is False
def test_base_anchor_bug811(): input_filename = 'bug811/font.pfa' feat_filename = 'bug811/feat.fea' ttx_filename = 'bug811.ttx' 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, ['GPOS']) expected_ttx = get_expected_path(ttx_filename) assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion'])
def test_add_table(): table_path = get_input_path('GDEF_italic.tb') font_path = get_input_path(ITALIC) actual_path = get_temp_file_path() assert font_has_table(font_path, 'GDEF') is False runner(CMD + ['-a', '-o', 'a', '_GDEF={}'.format(table_path), '-f', font_path, actual_path]) expected_path = get_expected_path('italic_w_GDEF.otf') assert differ([expected_path, actual_path, '-m', 'bin']) is False assert font_has_table(actual_path, 'GDEF') actual_ttx = generate_ttx_dump(actual_path) expected_ttx = generate_ttx_dump(expected_path) assert differ([expected_ttx, actual_ttx, '-s', ' <checkSumAdjustment'])
def test_fontsetplot(): f1 = 'SourceSansPro-Black.otf' f2 = 'SourceSansPro-BlackIt.otf' pdf_filename = "fontsetplot_otf_glyphs_2-7.pdf" fp1 = get_input_path(f1) fp2 = get_input_path(f2) save_path = get_temp_file_path() runner(['-t', 'fontsetplot', '-o', 'o', f'_{save_path}', 'dno', 'g', '_2-7', '=pageIncludeTitle', '_0', f'_{fp1}', f'_{fp2}']) expected_path = get_expected_path(pdf_filename) assert(differ([expected_path, save_path, '-s', '/CreationDate', '-e', 'macroman']))
def test_warnings_bug635(): font1_path = get_input_path('bug635/cidfont.ps') font2_path = get_input_path('bug635/rotated.ps') actual_path = get_temp_file_path() expected_path = get_expected_path('bug635.txt') warnings_path = runner( CMD + ['-s', '-e', '-a', '-f', actual_path, font1_path, font2_path]) # On Windows the messages start with 'mergefonts.exe:' with open(warnings_path, 'rb') as f: warnings = f.read().replace(b'mergefonts.exe:', b'mergefonts:') with open(warnings_path, 'wb') as f: f.write(warnings) assert differ([expected_path, warnings_path, '-l', '1,5-7,11-12'])
def test_warnings_bug635(): font1_path = get_input_path('bug635/cidfont.ps') font2_path = get_input_path('bug635/rotated.ps') actual_path = get_temp_file_path() expected_path = get_expected_path('bug635.txt') warnings_path = runner( CMD + ['-s', '-e', '-a', '-f', actual_path, font1_path, font2_path]) # On Windows the messages start with 'mergefonts.exe:' with open(warnings_path, 'rb') as f: warnings = f.read().replace(b'mergefonts.exe:', b'mergefonts:') with open(warnings_path, 'wb') as f: f.write(warnings) assert differ([expected_path, warnings_path, '-l', '1,5-7,11-12'])
def test_check_psname_in_fmndb_bug1171(explicit_fmndb): input_path = get_input_path('bug1171/font.ufo') fmndb_path = get_input_path('bug1171/FontMenuNameDB') expected_ttx = get_expected_path('bug1171.ttx') actual_path = get_temp_file_path() opts = ['-o', 'f', f'_{input_path}', 'o', f'_{actual_path}'] if explicit_fmndb is True: opts.extend(['mf', f'_{fmndb_path}']) runner(CMD + opts) actual_ttx = generate_ttx_dump(actual_path, ['name']) assert differ([ expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion', '-r', r'^\s+Version.*;hotconv.*;makeotfexe' ])
def test_ttf_input_font_bug680(): input_filename = 'bug680/font.ttf' feat_filename = 'bug680/features.fea' ttf_path = get_temp_file_path() runner(CMD + ['-o', 'r', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(ttf_path)]) for table_tag in ('head', 'hhea', 'maxp', 'OS/2', 'hmtx', 'cmap', 'fpgm', 'prep', 'cvt ', 'loca', 'glyf', 'name', 'post', 'gasp', 'BASE', 'GDEF', 'GPOS', 'GSUB'): assert font_has_table(ttf_path, table_tag)
def test_add_table(): table_path = get_input_path('GDEF_italic.tb') font_path = get_input_path(ITALIC) actual_path = get_temp_file_path() assert font_has_table(font_path, 'GDEF') is False runner( CMD + ['-a', '-o', 'a', f'_GDEF={table_path}', '-f', font_path, actual_path]) expected_path = get_expected_path('italic_w_GDEF.otf') assert differ([expected_path, actual_path, '-m', 'bin']) is False assert font_has_table(actual_path, 'GDEF') actual_ttx = generate_ttx_dump(actual_path) expected_ttx = generate_ttx_dump(expected_path) assert differ([expected_ttx, actual_ttx, '-s', ' <checkSumAdjustment'])
def test_ttf_input_font_bug680(): input_filename = 'bug680/font.ttf' feat_filename = 'bug680/features.fea' ttf_path = get_temp_file_path() runner(CMD + ['-o', 'r', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(ttf_path)]) for table_tag in ('head', 'hhea', 'maxp', 'OS/2', 'hmtx', 'cmap', 'fpgm', 'prep', 'cvt ', 'loca', 'glyf', 'name', 'post', 'gasp', 'BASE', 'GDEF', 'GPOS', 'GSUB'): assert font_has_table(ttf_path, table_tag)
def test_overflow_report_bug313(feat_name, error_msg): input_filename = 'bug313/font.pfa' feat_filename = 'bug313/{}.fea'.format(feat_name) otf_path = get_temp_file_path() stderr_path = runner( CMD + ['-s', '-e', '-o', 'shw', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stderr_path, 'rb') as f: output = f.read() assert error_msg in output
def test_parameter_offset_overflow_bug746(): input_filename = 'bug746/font.pfa' feat_filename = 'bug746/feat.fea' otf_path = get_temp_file_path() stderr_path = runner( CMD + ['-s', '-e', '-o', 'shw', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stderr_path, 'rb') as f: output = f.read() assert(b"[FATAL] <bug746> feature parameter offset too large") in output
def test_glyph_limit_error_bug1338(): """ Testing font with 65535 glyphs for string INDEX limit exceeded error instead of segfault error """ rtf_path = get_input_path("bug1338/bug1338-map.txt") font_path = get_input_path("bug1338/bug1338-font.pfa") actual_path = get_temp_file_path() cmd = CMD + ['-a', '-f', font_path, actual_path, '-o', 't1', 'rtf', f'_{rtf_path}'] with pytest.raises(subprocess.CalledProcessError) as err: runner(cmd) assert err.value.returncode == 35
def test_input_formats(arg, input_filename, ttx_filename): if 'gf' in arg: arg.append('_{}'.format(get_input_path('GOADB.txt'))) actual_path = get_temp_file_path() runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)), 'o', '_{}'.format(actual_path)] + arg) actual_ttx = generate_ttx_dump(actual_path) expected_ttx = get_expected_path(ttx_filename) assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion' + SPLIT_MARKER + ' <checkSumAdjustment value=' + SPLIT_MARKER + ' <created value=' + SPLIT_MARKER + ' <modified value=', '-r', r'^\s+Version.*;hotconv.*;makeotfexe'])
def test_input_formats(arg, input_filename, ttx_filename): if 'gf' in arg: arg.append('_{}'.format(get_input_path('GOADB.txt'))) actual_path = get_temp_file_path() runner(CMD + ['-o', 'f', '_{}'.format(get_input_path(input_filename)), 'o', '_{}'.format(actual_path)] + arg) actual_ttx = generate_ttx_dump(actual_path) expected_ttx = get_expected_path(ttx_filename) assert differ([expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion' + SPLIT_MARKER + ' <checkSumAdjustment value=' + SPLIT_MARKER + ' <created value=' + SPLIT_MARKER + ' <modified value=', '-r', r'^\s+Version.*;hotconv.*;makeotfexe'])
def test_feature_recursion_bug628(): input_filename = 'bug628/font.pfa' feat_filename = 'bug628/feat.fea' otf_path = get_temp_file_path() stderr_path = runner( CMD + ['-s', '-e', '-o', 'shw', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stderr_path, 'rb') as f: output = f.read() assert(b"[FATAL] <SourceSans-Test> Can't include [feat.fea]; maximum " b"include levels <50> reached") in output
def test_overflow_bug731(): input_filename = 'bug731/font.pfa' feat_filename = 'bug731/feat.fea' otf_path = get_temp_file_path() stderr_path = runner( CMD + ['-s', '-e', '-o', 'shw', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stderr_path, 'rb') as f: output = f.read() assert(b"[FATAL] <SourceSans-Test> subtable offset too large (1003c) in " b"lookup 0 type 3") in output
def test_version_warning_bug610(): input_filename = 'bug610/font.pfa' feat_filename = 'bug610/v0005.fea' otf_path = get_temp_file_path() stderr_path = runner( CMD + ['-s', '-e', '-o', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stderr_path, 'rb') as f: output = f.read() assert (b"[WARNING] <SourceSans-Test> Major version number not in " b"range 1 .. 255") not in output
def test_read_fdselect_format_4(option): font_name = 'fdselect4.otf' input_path = get_input_path(font_name) output_path = get_temp_file_path() runner(CMD + ['-a', '-o', option, '-f', input_path, output_path]) expected_path = get_expected_path(font_name + '.' + option) assert differ([expected_path, output_path, '-s', '## Filename'])
def test_remove_overlap(args, ufo_filename, expct_label): actual_path = os.path.join(tempfile.mkdtemp(), ufo_filename) copytree(get_input_path(ufo_filename), actual_path) runner(CMD + ['-f', actual_path, '-o'] + args) expct_filename = '{}-{}'.format(ufo_filename[:-4], expct_label) expected_path = get_expected_path(expct_filename) assert differ([expected_path, actual_path])
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)
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'])
def test_glyph_not_in_font_bug492(): input_filename = 'bug492/font.pfa' feat_filename = 'bug492/features.fea' otf_path = get_temp_file_path() stderr_path = runner( CMD + ['-s', '-e', '-o', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stderr_path, 'rb') as f: output = f.read() assert (b'[ERROR] <SourceSans-Test> Glyph "glyph_not_found" not in font. ' b'[') in output assert (b'syntax error at "a" [') not in output
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'])
def test_readOptionFile(): INPUT_FONT_NAME = 'font.pfa' OUTPUT_FONT_NAME = 'font.otf' proj_path = get_input_path('proj.txt') abs_font_dir_path = os.path.dirname(proj_path) params = MakeOTFParams() assert params.fontDirPath == '.' params.currentDir = os.path.dirname(proj_path) assert readOptionFile(proj_path, params, 1) == (True, 7) assert params.fontDirPath == '.' assert params.opt_InputFontPath == INPUT_FONT_NAME assert params.opt_OutputFontPath == OUTPUT_FONT_NAME assert params.opt_ConvertToCID == 'true' assert params.opt_kSetfsSelectionBitsOff == '[8, 9]' assert params.opt_kSetfsSelectionBitsOn == '[7]' assert params.seenOS2v4Bits == [1, 1, 1] assert params.opt_UseOldNameID4 is None params.currentDir = os.getcwd() font_dir_path = os.path.relpath(abs_font_dir_path, params.currentDir) input_font_path = os.path.join(font_dir_path, INPUT_FONT_NAME) output_font_path = os.path.join(font_dir_path, OUTPUT_FONT_NAME) assert readOptionFile(proj_path, params, 1) == (True, 7) assert params.fontDirPath == os.path.normpath(font_dir_path) assert params.opt_InputFontPath == os.path.normpath(input_font_path) assert params.opt_OutputFontPath == os.path.normpath(output_font_path)
def test_readOptionFile(): INPUT_FONT_NAME = 'font.pfa' OUTPUT_FONT_NAME = 'font.otf' proj_path = get_input_path('proj.txt') abs_font_dir_path = os.path.dirname(proj_path) params = MakeOTFParams() assert params.fontDirPath == '.' params.currentDir = os.path.dirname(proj_path) assert readOptionFile(proj_path, params, 1) == (True, 7) assert params.fontDirPath == '.' assert params.opt_InputFontPath == INPUT_FONT_NAME assert params.opt_OutputFontPath == OUTPUT_FONT_NAME assert params.opt_ConvertToCID == 'true' assert params.opt_kSetfsSelectionBitsOff == '[8, 9]' assert params.opt_kSetfsSelectionBitsOn == [7] assert params.seenOS2v4Bits == [1, 1, 1] assert params.opt_UseOldNameID4 is None params.currentDir = os.getcwd() font_dir_path = os.path.relpath(abs_font_dir_path, params.currentDir) input_font_path = os.path.join(font_dir_path, INPUT_FONT_NAME) output_font_path = os.path.join(font_dir_path, OUTPUT_FONT_NAME) assert readOptionFile(proj_path, params, 1) == (True, 7) assert params.fontDirPath == os.path.normpath(font_dir_path) assert params.opt_InputFontPath == os.path.normpath(input_font_path) assert params.opt_OutputFontPath == os.path.normpath(output_font_path)
def test_readOptionFile_relpath(cur_dir_str): INPUT_FONT_NAME = 'font.pfa' OUTPUT_FONT_NAME = 'font.otf' proj_path = get_input_path('proj2.txt') abs_font_dir_path = os.path.dirname(proj_path) params = MakeOTFParams() if '/' in cur_dir_str: # flip the slashes used in the test's input string params.currentDir = os.path.normpath(cur_dir_str) else: params.currentDir = cur_dir_str font_dir_path = os.path.relpath(abs_font_dir_path, params.currentDir) if cur_dir_str.startswith('..') and os.path.dirname(os.getcwd()) == os.sep: # the project is inside a folder located at the root level; # remove the two dots at the start of the path, otherwise # testing input '../different_dir' will fail. font_dir_path = font_dir_path[2:] input_font_path = os.path.join(font_dir_path, INPUT_FONT_NAME) output_font_path = os.path.join(font_dir_path, OUTPUT_FONT_NAME) assert readOptionFile(proj_path, params, 1) == (False, 3) assert params.fontDirPath == os.path.normpath(font_dir_path) assert params.opt_InputFontPath == os.path.normpath(input_font_path) assert params.opt_OutputFontPath == os.path.normpath(output_font_path)
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'])
def test_fetch_font_version_bug610(feat_name, has_warn): input_filename = 't1pfa.pfa' feat_filename = 'bug610/{}.fea'.format(feat_name) otf_path = get_temp_file_path() stdout_path = runner( CMD + ['-s', '-o', 'r', 'f', '_{}'.format(get_input_path(input_filename)), 'ff', '_{}'.format(get_input_path(feat_filename)), 'o', '_{}'.format(otf_path)]) with open(stdout_path, 'rb') as f: output = f.read() assert b"Revision 0.005" in output assert (b"[Warning] Major version number not in " b"range 1 .. 255" in output) is has_warn
def test_write_fdselect_format_4(): font_name = 'FDArrayTest257FontDicts.otf' input_path = get_input_path(font_name) output_path = get_temp_file_path() runner(CMD + ['-a', '-o', 'cff2', '-f', input_path, output_path]) expected_path = get_expected_path('FDArrayTest257FontDicts.cff2') assert differ([expected_path, output_path, '-m', 'bin'])
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
def test_ttread_varinst(): font_path = get_input_path('AdobeVFPrototype.ttf') save_path = get_temp_file_path() runner(CMD + ['-a', '-o', '3', 'g', '_A', 'U', '_500,800', '-f', font_path, save_path]) expected_path = get_expected_path('vfproto_tt_inst500_800.txt') assert differ([expected_path, save_path, '-s', '## Filename'])
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_readOptionFile_relpath(cur_dir_str): INPUT_FONT_NAME = 'font.pfa' OUTPUT_FONT_NAME = 'font.otf' proj_path = get_input_path('proj2.txt') abs_font_dir_path = os.path.dirname(proj_path) params = MakeOTFParams() if '/' in cur_dir_str: # flip the slashes used in the test's input string params.currentDir = os.path.normpath(cur_dir_str) else: params.currentDir = cur_dir_str font_dir_path = os.path.relpath(abs_font_dir_path, params.currentDir) if cur_dir_str.startswith('..') and os.path.dirname(os.getcwd()) == os.sep: # the project is inside a folder located at the root level; # remove the two dots at the start of the path, otherwise # testing input '../different_dir' will fail. font_dir_path = font_dir_path[2:] input_font_path = os.path.join(font_dir_path, INPUT_FONT_NAME) output_font_path = os.path.join(font_dir_path, OUTPUT_FONT_NAME) assert readOptionFile(proj_path, params, 1) == (False, 3) assert params.fontDirPath == os.path.normpath(font_dir_path) assert params.opt_InputFontPath == os.path.normpath(input_font_path) assert params.opt_OutputFontPath == os.path.normpath(output_font_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'])
def test_cjk_var(): """ Builds all OTFs for the 'CJKVar' project and then diffs two of them. """ input_dir = get_input_path('CJKVar') temp_dir = os.path.join(tempfile.mkdtemp(), 'CJKVar') copytree(input_dir, temp_dir) ds_path = os.path.join(temp_dir, 'CJKVar.designspace') runner(CMD + ['-o', '_{}'.format(ds_path)]) otf1_path = os.path.join(temp_dir, 'Normal', 'Master_8', 'MasterSet_Kanji-w600.00.otf') otf2_path = os.path.join(temp_dir, 'Condensed', 'Master_8', 'MasterSet_Kanji_75-w600.00.otf') for otf_path in (otf1_path, otf2_path): actual_ttx = generate_ttx_dump(otf_path) expected_ttx = get_expected_path( os.path.basename(otf_path)[:-3] + 'ttx') assert differ([ expected_ttx, actual_ttx, '-s', '<ttFont sfntVersion' + SPLIT_MARKER + ' <checkSumAdjustment value=' + SPLIT_MARKER + ' <created value=' + SPLIT_MARKER + ' <modified value=', '-r', r'^\s+Version.*;hotconv.*;makeotfexe' ])
def test_mergeFontToCFF_bug570(font_filename, subroutinize): # 'dir=TEMP_DIR' is used for guaranteeing that the temp data is on same # file system as other data; if it's not, a file rename step made by # sfntedit will NOT work. actual_path = get_temp_file_path(directory=TEMP_DIR) subr_str = 'subr' if subroutinize else 'no_subr' ttx_filename = '{}-{}.ttx'.format(font_filename.split('.')[0], subr_str) source_path = get_input_path(font_filename) output_path = get_input_path('core.otf') copy2(output_path, actual_path) mergeFontToCFF(source_path, actual_path, subroutinize) actual_ttx = generate_ttx_dump(actual_path, ['CFF ']) expected_ttx = get_expected_path(ttx_filename) assert differ([expected_ttx, actual_ttx, '-l', '2'])