Ejemplo n.º 1
0
 def it_catalogs_the_system_fonts_to_help_find(self, installed_fixture):
     expected_call_args, expected_values = installed_fixture
     installed_fonts = FontFiles._installed_fonts()
     assert FontFiles._iter_font_files_in.call_args_list == (
         expected_call_args
     )
     assert installed_fonts == expected_values
Ejemplo n.º 2
0
    def it_iterates_over_fonts_in_dir_to_help_find(self, iter_fixture):
        directory, _Font_, expected_calls, expected_paths = iter_fixture

        paths = list(FontFiles._iter_font_files_in(directory))

        assert _Font_.open.call_args_list == expected_calls
        assert paths == expected_paths
Ejemplo n.º 3
0
    def it_iterates_over_fonts_in_dir_to_help_find(self, iter_fixture):
        directory, _Font_, expected_calls, expected_paths = iter_fixture
        paths = list(FontFiles._iter_font_files_in(directory))

        print(directory)

        assert _Font_.open.call_args_list == expected_calls
        assert paths == expected_paths
Ejemplo n.º 4
0
    def _can_i_haz_linux(cls):

        if sys.platform.startswith("linux"):
            return {
                # python-pptx fails if Calibri isn't found, so reroute it to a local font file
                ('Calibri', False, False): '/usr/share/fonts/truetype/freefont/FreeSans.ttf',
            }
        else:
            return FontFiles._old_installed_fonts()
Ejemplo n.º 5
0
    def _can_i_haz_linux(cls):

        if sys.platform.startswith("linux"):
            return {
                # python-pptx fails if Calibri isn't found, so reroute it to a local font file
                ('Calibri', False, False):
                '/usr/share/fonts/truetype/freefont/FreeSans.ttf',
            }
        else:
            return FontFiles._old_installed_fonts()
Ejemplo n.º 6
0
 def _best_fit_font_size(self, family, max_size, bold, italic, font_file):
     """
     Return the largest integer point size not greater than *max_size*
     that allows all the text in this text frame to fit inside its extents
     when rendered using the font described by *family*, *bold*, and
     *italic*. If *font_file* is specified, it is used to calculate the
     fit, whether or not it matches *family*, *bold*, and *italic*.
     """
     if font_file is None:
         font_file = FontFiles.find(family, bold, italic)
     return TextFitter.best_fit_font_size(self.text, self._extents,
                                          max_size, font_file)
Ejemplo n.º 7
0
 def _best_fit_font_size(self, family, max_size, bold, italic, font_file):
     """
     Return the largest integer point size not greater than *max_size*
     that allows all the text in this text frame to fit inside its extents
     when rendered using the font described by *family*, *bold*, and
     *italic*. If *font_file* is specified, it is used to calculate the
     fit, whether or not it matches *family*, *bold*, and *italic*.
     """
     if font_file is None:
         font_file = FontFiles.find(family, bold, italic)
     return TextFitter.best_fit_font_size(
         self.text, self._extents, max_size, font_file
     )
 def it_generates_font_dirs_to_help_find(self, font_dirs_fixture):
     expected_values = font_dirs_fixture
     font_dirs = FontFiles._font_directories()
     assert font_dirs == expected_values
 def it_catalogs_the_system_fonts_to_help_find(self, installed_fixture):
     expected_call_args, expected_values = installed_fixture
     installed_fonts = FontFiles._installed_fonts()
     assert FontFiles._iter_font_files_in.call_args_list == (
         expected_call_args)
     assert installed_fonts == expected_values
Ejemplo n.º 10
0
 def it_can_find_a_system_font_file(self, find_fixture):
     family_name, is_bold, is_italic, expected_path = find_fixture
     path = FontFiles.find(family_name, is_bold, is_italic)
     assert path == expected_path
Ejemplo n.º 11
0
 def it_knows_windows_font_dirs_to_help_find(self, win_dirs_fixture):
     expected_dirs = win_dirs_fixture
     font_dirs = FontFiles._windows_font_directories()
     assert font_dirs == expected_dirs
Ejemplo n.º 12
0
 def it_knows_os_x_font_dirs_to_help_find(self, osx_dirs_fixture):
     expected_dirs = osx_dirs_fixture
     font_dirs = FontFiles._os_x_font_directories()
     assert font_dirs == expected_dirs
Ejemplo n.º 13
0
 def it_generates_font_dirs_to_help_find(self, font_dirs_fixture):
     expected_values = font_dirs_fixture
     font_dirs = FontFiles._font_directories()
     assert font_dirs == expected_values
Ejemplo n.º 14
0
 def it_can_find_a_system_font_file(self, find_fixture):
     family_name, is_bold, is_italic, expected_path = find_fixture
     path = FontFiles.find(family_name, is_bold, is_italic)
     assert path == expected_path
Ejemplo n.º 15
0
 def it_knows_os_x_font_dirs_to_help_find(self, osx_dirs_fixture):
     expected_dirs = osx_dirs_fixture
     font_dirs = FontFiles._os_x_font_directories()
     assert font_dirs == expected_dirs
Ejemplo n.º 16
0
 def it_knows_windows_font_dirs_to_help_find(self, win_dirs_fixture):
     expected_dirs = win_dirs_fixture
     font_dirs = FontFiles._windows_font_directories()
     assert font_dirs == expected_dirs
Ejemplo n.º 17
0
 def it_knows_linuxdows_font_dirs_to_help_find(self, linux_dirs_fixture):
     expected_dirs = linux_dirs_fixture
     font_dirs = FontFiles._linux_font_directories()
     assert font_dirs == expected_dirs