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_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_abspath(): proj_path = get_input_path('proj2.txt') params = MakeOTFParams() root = os.path.abspath(os.sep) params.currentDir = os.path.join(root, 'different_dir') assert readOptionFile(proj_path, params, 1) == (False, 3) assert params.fontDirPath.startswith(root) assert params.opt_InputFontPath.startswith(root) assert params.opt_OutputFontPath.startswith(root)
def test_writeOptionsFile(): actual_path = get_temp_file_path() expected_path = get_expected_path('proj_write.txt') params = MakeOTFParams() params.currentDir = os.path.dirname(actual_path) params.opt_InputFontPath = 'font.pfa' params.opt_OutputFontPath = 'fôñt.otf' params.opt_kSetfsSelectionBitsOn = [7] params.opt_kSetfsSelectionBitsOff = [9, 8] params.opt_ConvertToCID = 'true' params.opt_kSetOS2Version = 3 params.verbose = True # set options's sort order kMOTFOptions['InputFontPath'][0] = 1 kMOTFOptions['OutputFontPath'][0] = kOptionNotSeen + 1 kMOTFOptions['kSetfsSelectionBitsOn'][0] = 30 writeOptionsFile(params, actual_path) assert differ([expected_path, actual_path])
def test_readOptionFile_filenotfound(): proj_path = get_input_path('notafile') params = MakeOTFParams() params.currentDir = os.getcwd() assert readOptionFile(proj_path, params, 0) == (True, 0)
def test_options_cs_cl_bug459(args, result): params = MakeOTFParams() getOptions(params, args) assert params.opt_MacCmapScriptID == result[0] assert params.opt_MacCmapLanguageID == result[1]
def test_options_shw_nshw_bug457(args, result): params = MakeOTFParams() getOptions(params, args) assert params.opt_ReleaseMode == result[0] assert params.opt_SuppressHintWarnings == result[1]