def test_does_not_add_same_font_twice(self): loader = FontLoader( [get_file_in_test_directory(''), get_file_in_test_directory('')], True) data = { StyleInfo('Jorvik', 0, False): UsageData(), StyleInfo('Jorvik informal', 0, False): UsageData() } found, not_found = loader.get_fonts_for_list(data) self.assertEqual(1, len(found))
def test_correctly_finds_yanone_kaffeesatz_bold(self): logging.basicConfig(level=logging.DEBUG) f = TTFFont(get_file_in_test_directory('YanoneKaffeesatz-Bold.otf')) print(f.get_info().weight) f.print_headers() stat = AssParser.get_fonts_statistics(get_file_in_test_directory('3.ass'), True, True) loader = FontLoader([get_file_in_test_directory('')]) found, not_found = loader.get_fonts_for_list(stat) self.assertFalse(not_found) logging.disable(logging.DEBUG)
def test_correctly_finds_yanone_kaffeesatz_bold(self): logging.basicConfig(level=logging.DEBUG) f = TTFFont(get_file_in_test_directory('YanoneKaffeesatz-Bold.otf')) print(f.get_info().weight) f.print_headers() stat = AssParser.get_fonts_statistics( get_file_in_test_directory('3.ass'), True, True) loader = FontLoader([get_file_in_test_directory('')]) found, not_found = loader.get_fonts_for_list(stat) self.assertFalse(not_found) logging.disable(logging.DEBUG)
def test_returns_all_found_fonts(self): loader = FontLoader([get_file_in_test_directory('')], True) data = { StyleInfo('Jorvik Informal V2', 0, False): UsageData(), StyleInfo('Random font', 0, False): UsageData() } found, not_found = loader.get_fonts_for_list(data) self.assertEqual(1, len(found)) self.assertIn('Jorvik Informal V2', list(found.values())[0].names)
def test_contains_all_names(self): font = TTCFont(get_file_in_test_directory('jorvik_and_seriously.ttc')) self.assertIn( 'Seriously', reduce(lambda names, info: names + info.names, font.get_infos(), [])) self.assertIn( 'Jorvik Informal V2', reduce(lambda names, info: names + info.names, font.get_infos(), []))
def test_caches_md5_in_private_field(self): info = FontInfo([], False, False, 0, get_file_in_test_directory('Jorvik.ttf'), None) self.assertIsNone(info._FontInfo__md5) md5 = info.md5 self.assertIsNotNone(info._FontInfo__md5)
def test_calculates_md5_on_access(self): info = FontInfo([], False, False, 0, get_file_in_test_directory('Jorvik.ttf'), None) self.assertIsNotNone(info.md5)
def test_does_not_remove_styles_used_in_r(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory('2.ass'), True, True) styles = set() for info in stat.values(): styles.update(info.styles) self.assertIn('EDromajiEng', styles)
def test_gets_correct_count_of_styles_font_used_in(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory('1.ass'), True, True) for key, value in stat.items(): if key.fontname == 'YANEF': found = value self.assertEqual(len(found.styles), 1)
def test_detects_regular_weight(self): font = TTFFont(get_file_in_test_directory('Jorvik.ttf')) self.assertEqual(font.get_info().weight, FontWeight.FW_NORMAL)
def test_parses_fonts_with_utf8_platform_id_0_strings(self): font = TTFFont(get_file_in_test_directory('SUSANNA_.otf')) self.assertIn('Susanna', font.get_info().names)
def test_jorvik_v2_name_matches(self): font = TTFFont(get_file_in_test_directory('Jorvik.ttf')) self.assertIn('Jorvik Informal V2', font.get_info().names)
def test_caches_md5_in_private_field(self): info = FontInfo([], False, False, 0, get_file_in_test_directory('Jorvik.ttf'), None) self.assertIsNone(info._FontInfo__md5) md5 = info.md5 self.assertIsNotNone(info._FontInfo__md5)
def test_calculates_correct_md5(self): info = FontInfo([], False, False, 0, get_file_in_test_directory('Jorvik.ttf'), None) self.assertEqual(info.md5, '0dae05c47e919281d7ac1e0170e4d3a8')
def test_calculates_md5_on_access(self): info = FontInfo([], False, False, 0, get_file_in_test_directory('Jorvik.ttf'), None) self.assertIsNotNone(info.md5)
def test_detects_medium_weight(self): font = TTFFont(get_file_in_test_directory('seriously.ttf')) self.assertEqual(font.get_info().weight, FontWeight.FW_MEDIUM)
def test_performs_case_insensitive_search(self): loader = FontLoader([get_file_in_test_directory('')], True) data = {StyleInfo('JoRvIk INFormAl v2', 0, False) : UsageData()} found, not_found = loader.get_fonts_for_list(data) self.assertEqual(1, len(found))
def test_performs_case_insensitive_search(self): loader = FontLoader([get_file_in_test_directory('')], True) data = {StyleInfo('JoRvIk INFormAl v2', 0, False): UsageData()} found, not_found = loader.get_fonts_for_list(data) self.assertEqual(1, len(found))
def test_ttf_name_matches(self): font = TTFFont(get_file_in_test_directory('seriously.ttf')) self.assertIn('Seriously', font.get_info().names)
def test_parses_fonts_with_utf8_platform_id_0_strings(self): font = TTFFont(get_file_in_test_directory('SUSANNA_.otf')) self.assertIn('Susanna', font.get_info().names)
def test_detects_italic_bold_font(self): font = TTFFont(get_file_in_test_directory('CaviarDreams_BoldItalic.ttf')) self.assertIs(font.get_info().italic, True) self.assertIs(font.get_info().bold, True)
def test_ttf_name_matches(self): font = TTFFont(get_file_in_test_directory('seriously.ttf')) self.assertIn('Seriously', font.get_info().names)
def test_detects_regular_weight(self): font = TTFFont(get_file_in_test_directory('Jorvik.ttf')) self.assertEqual(font.get_info().weight, FontWeight.FW_NORMAL)
def test_otf_name_matches(self): font = TTFFont(get_file_in_test_directory('otfpoc.otf')) self.assertIn('otfpoc', font.get_info().names)
def test_returns_correct_number_of_all_fonts_in_bakemono_script_without_unused_fonts_and_comments(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory('1.ass'), True, True) self.assertEqual(len(stat), 17)
def test_jorvik_v2_name_matches(self): font = TTFFont(get_file_in_test_directory('Jorvik.ttf')) self.assertIn('Jorvik Informal V2', font.get_info().names)
def test_gets_correct_count_of_lines_font_used_in(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory('1.ass'), False, False) for key, value in stat.items(): if key.fontname == 'this is totally not real font': found = value self.assertEqual(len(found.lines), 1)
def test_detects_bold_only_font(self): font = TTFFont(get_file_in_test_directory('Caviar Dreams Bold.ttf')) self.assertIs(font.get_info().bold, True)
def test_contains_all_names(self): font = TTCFont(get_file_in_test_directory('jorvik_and_seriously.ttc')) self.assertIn('Seriously', reduce(lambda names, info: names + info.names, font.get_infos(), [])) self.assertIn('Jorvik Informal V2', reduce(lambda names, info: names + info.names, font.get_infos(), []))
def test_detects_italic_bold_font(self): font = TTFFont( get_file_in_test_directory('CaviarDreams_BoldItalic.ttf')) self.assertIs(font.get_info().italic, True) self.assertIs(font.get_info().bold, True)
def test_calculates_correct_md5(self): info = FontInfo([], False, False, 0, get_file_in_test_directory('Jorvik.ttf'), None) self.assertEqual(info.md5, '0dae05c47e919281d7ac1e0170e4d3a8')
def test_returns_correct_number_of_all_fonts_in_bakemono_script(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory("1.ass"), False, False) self.assertEqual(len(stat), 19)
def test_returns_all_found_fonts(self): loader = FontLoader([get_file_in_test_directory('')], True) data = {StyleInfo('Jorvik Informal V2', 0, False) : UsageData(), StyleInfo('Random font', 0, False) : UsageData()} found, not_found = loader.get_fonts_for_list(data) self.assertEqual(1, len(found)) self.assertIn('Jorvik Informal V2', list(found.values())[0].names)
def test_returns_correct_number_of_all_fonts_in_bakemono_script_without_unused_fonts_and_comments(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory("1.ass"), True, True) self.assertEqual(len(stat), 17)
def test_does_not_add_same_font_twice(self): loader = FontLoader([get_file_in_test_directory(''), get_file_in_test_directory('')], True) data = {StyleInfo('Jorvik', 0, False) : UsageData(), StyleInfo('Jorvik informal', 0, False) : UsageData()} found, not_found = loader.get_fonts_for_list(data) self.assertEqual(1, len(found))
def test_gets_correct_count_of_styles_font_used_in(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory("1.ass"), True, True) for key, value in stat.items(): if key.fontname == "YANEF": found = value self.assertEqual(len(found.styles), 1)
def test_otf_name_matches(self): font = TTFFont(get_file_in_test_directory('otfpoc.otf')) self.assertIn('otfpoc', font.get_info().names)
def test_gets_correct_count_of_lines_font_used_in(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory("1.ass"), False, False) for key, value in stat.items(): if key.fontname == "this is totally not real font": found = value self.assertEqual(len(found.lines), 1)
def test_detects_bold_only_font(self): font = TTFFont(get_file_in_test_directory('Caviar Dreams Bold.ttf')) self.assertIs(font.get_info().bold, True)
def test_does_not_remove_styles_used_in_r(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory("2.ass"), True, True) styles = set() for info in stat.values(): styles.update(info.styles) self.assertIn("EDromajiEng", styles)
def test_parses_fonts_with_platform_id_2_strings(self): font = TTFFont(get_file_in_test_directory('VANTATHI.TTF')) self.assertIn('Vanta Thin', font.get_info().names)
def test_parses_fonts_with_platform_id_2_strings(self): font = TTFFont(get_file_in_test_directory('VANTATHI.TTF')) self.assertIn('Vanta Thin', font.get_info().names)
def test_detects_bold_weight(self): font = TTFFont(get_file_in_test_directory('Caviar Dreams Bold.ttf')) self.assertEqual(font.get_info().weight, FontWeight.FW_BOLD)
def test_returns_correct_number_of_all_fonts_in_bakemono_script(self): stat = AssParser.get_fonts_statistics(get_file_in_test_directory('1.ass'), False, False) self.assertEqual(len(stat), 19)
def test_detects_medium_weight(self): font = TTFFont(get_file_in_test_directory('seriously.ttf')) self.assertEqual(font.get_info().weight, FontWeight.FW_MEDIUM)
def test_detects_bold_weight(self): font = TTFFont(get_file_in_test_directory('Caviar Dreams Bold.ttf')) self.assertEqual(font.get_info().weight, FontWeight.FW_BOLD)