Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
def process(args):
    config = get_config(args)

    fonts = AssParser.get_fonts_statistics(os.path.abspath(config['script']),
                                           config['exclude_unused_fonts'],
                                           config['exclude_comments'])
    if config['rebuild_cache']:
        FontLoader.discard_cache()

    collector = FontLoader(config['font_dirs'], config['include_system_fonts'])
    found, not_found, paths = collector.get_fonts_for_list(fonts)

    if len(not_found) != 0:
        print(file=sys.stderr, *not_found, sep="\n")
        sys.exit(1)
    elif len(found) != 0:
        print(*paths, sep="\n")
Пример #4
0
Файл: assfc.py Проект: tp7/assfc
def process(args):
    config = get_config(args)
    set_logging(config['log_file'], config['verbose'])

    logging.debug(str(config))

    start_time = time()
    logging.info('-----Started new task at %s-----' % str(ctime()))

    fonts =  AssParser.get_fonts_statistics(os.path.abspath(config['script']), config['exclude_unused_fonts'], config['exclude_comments'])

    if config['rebuild_cache']:
        FontLoader.discard_cache()

    collector = FontLoader(config['font_dirs'], config['include_system_fonts'])

    found, not_found = collector.get_fonts_for_list(fonts)

    for font, usage in not_found.items():
        text = "Could not find font '%s'" % str(font)
        if usage.styles:
            text += '\nUsed in styles %s' % str(usage.styles)
        if usage.lines:
            if len(usage.lines) > 50:
                text += '\nUsed on more than 50 lines'
            else:
                text += '\nUsed on lines %s' % str(usage.lines)
        text += '\n\n'
        logging.warning(text)

    logging.info('Total found: %i', len(found))
    logging.info('Total not found: %i', len(not_found))

    if config['output_location'] is not None:
        if config['output_location'].endswith('.mks'):
            create_mks_file(config['mmg'], config['output_location'], config['script'], found.values())
        else:
            copy_fonts_to_folder(config['output_location'], found.values())

    logging.debug('Job done in %fs' % round(time() - start_time, 5))
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 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)
Пример #13
0
 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)
Пример #14
0
 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)