def test_varlib_main_ttf(self): """Mostly for testing varLib.main() """ suffix = '.ttf' ds_path = self.get_test_input('Build.designspace') ufo_dir = self.get_test_input('master_ufo') ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf') self.temp_dir() ttf_dir = os.path.join(self.tempdir, 'master_ttf_interpolatable') os.makedirs(ttf_dir) ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-') for path in ttx_paths: self.compile_font(path, suffix, ttf_dir) ds_copy = os.path.join(self.tempdir, 'BuildMain.designspace') shutil.copy2(ds_path, ds_copy) varLib_main([ds_copy]) varfont_path = os.path.splitext(ds_copy)[0] + '-VF' + suffix varfont = TTFont(varfont_path) tables = [ table_tag for table_tag in varfont.keys() if table_tag != 'head' ] expected_ttx_path = self.get_test_output('BuildMain.ttx') self.expect_ttx(varfont, expected_ttx_path, tables)
def test_varlib_main_ttf(self): """Mostly for testing varLib.main() """ suffix = '.ttf' ds_path = self.get_test_input('Build.designspace') ufo_dir = self.get_test_input('master_ufo') ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf') self.temp_dir() ttf_dir = os.path.join(self.tempdir, 'master_ttf_interpolatable') os.makedirs(ttf_dir) ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-') for path in ttx_paths: self.compile_font(path, suffix, ttf_dir) ds_copy = os.path.join(self.tempdir, 'BuildMain.designspace') shutil.copy2(ds_path, ds_copy) varLib_main([ds_copy]) varfont_path = os.path.splitext(ds_copy)[0] + '-VF' + suffix varfont = TTFont(varfont_path) tables = [table_tag for table_tag in varfont.keys() if table_tag != 'head'] expected_ttx_path = self.get_test_output('BuildMain.ttx') self.expect_ttx(varfont, expected_ttx_path, tables)
def test_varlib_main_ttf(self): """Mostly for testing varLib.main() """ suffix = '.ttf' ds_path = self.get_test_input('Build.designspace') ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf') self.temp_dir() ttf_dir = os.path.join(self.tempdir, 'master_ttf_interpolatable') os.makedirs(ttf_dir) ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-') for path in ttx_paths: self.compile_font(path, suffix, ttf_dir) ds_copy = os.path.join(self.tempdir, 'BuildMain.designspace') shutil.copy2(ds_path, ds_copy) # by default, varLib.main finds master TTFs inside a # 'master_ttf_interpolatable' subfolder in current working dir cwd = os.getcwd() os.chdir(self.tempdir) try: varLib_main([ds_copy]) finally: os.chdir(cwd) varfont_path = os.path.splitext(ds_copy)[0] + '-VF' + suffix self.assertTrue(os.path.exists(varfont_path)) # try again passing an explicit --master-finder os.remove(varfont_path) finder = "%s/master_ttf_interpolatable/{stem}.ttf" % self.tempdir varLib_main([ds_copy, "--master-finder", finder]) self.assertTrue(os.path.exists(varfont_path)) # and also with explicit -o output option os.remove(varfont_path) varfont_path = os.path.splitext(varfont_path)[0] + "-o" + suffix varLib_main([ds_copy, "-o", varfont_path, "--master-finder", finder]) self.assertTrue(os.path.exists(varfont_path)) varfont = TTFont(varfont_path) tables = [ table_tag for table_tag in varfont.keys() if table_tag != 'head' ] expected_ttx_path = self.get_test_output('BuildMain.ttx') self.expect_ttx(varfont, expected_ttx_path, tables)
def test_varlib_main_ttf(self): """Mostly for testing varLib.main() """ suffix = '.ttf' ds_path = self.get_test_input('Build.designspace') ttx_dir = self.get_test_input('master_ttx_interpolatable_ttf') self.temp_dir() ttf_dir = os.path.join(self.tempdir, 'master_ttf_interpolatable') os.makedirs(ttf_dir) ttx_paths = self.get_file_list(ttx_dir, '.ttx', 'TestFamily-') for path in ttx_paths: self.compile_font(path, suffix, ttf_dir) ds_copy = os.path.join(self.tempdir, 'BuildMain.designspace') shutil.copy2(ds_path, ds_copy) # by default, varLib.main finds master TTFs inside a # 'master_ttf_interpolatable' subfolder in current working dir cwd = os.getcwd() os.chdir(self.tempdir) try: varLib_main([ds_copy]) finally: os.chdir(cwd) varfont_path = os.path.splitext(ds_copy)[0] + '-VF' + suffix self.assertTrue(os.path.exists(varfont_path)) # try again passing an explicit --master-finder os.remove(varfont_path) finder = "%s/master_ttf_interpolatable/{stem}.ttf" % self.tempdir varLib_main([ds_copy, "--master-finder", finder]) self.assertTrue(os.path.exists(varfont_path)) # and also with explicit -o output option os.remove(varfont_path) varfont_path = os.path.splitext(varfont_path)[0] + "-o" + suffix varLib_main([ds_copy, "-o", varfont_path, "--master-finder", finder]) self.assertTrue(os.path.exists(varfont_path)) varfont = TTFont(varfont_path) tables = [table_tag for table_tag in varfont.keys() if table_tag != 'head'] expected_ttx_path = self.get_test_output('BuildMain.ttx') self.expect_ttx(varfont, expected_ttx_path, tables)