Пример #1
0
    def process_resource_entry(self, target, ext, css_media, prefix, resource):
        """
        Process the given (raw) resource.
        """
        prefix, resource = super(ResourceManagerExtension,
                                 self).process_resource_entry(
                                     target, ext, css_media, prefix, resource)

        # if we are rendering css and the resource is a font,
        # then substitude it with its corresponding font css
        # file
        if ext == '.css' and prefix == 'font':
            font_declaration = FontCache.get_font_declaration(resource)
            if font_declaration is not None:
                resource = FontCache.get_font_css_url(
                    font_declaration.font_name)
                prefix = 'screen'

        return prefix, resource
Пример #2
0
    def handle(self, *args, **options):
        """
        Run command.
        """
        fontcache = FontCache()

        # clear first if we are refreshing the cache
        if options.get('refresh'):
            fontcache.clear(verbose=True)

        # update font cache
        fontcache.update(verbose=True)
Пример #3
0
 def test_should_patrse_font_declaration(self):
     d = FontCache.get_font_declaration('Open Sans:300,300i')
     self.assertIsInstance(d, FontDeclaration)
     self.assertEqual('Open Sans', d.font_name)
     self.assertEqual(['300', '300i'], d.variants_display)
Пример #4
0
 def setUp(self):
     self.fontcache = FontCache()
Пример #5
0
 def test_should_return_media_url_path_to_font_declaration_css_file(self):
     self.assertEqual('/media/fonts/open-sans/open-sans.css',
                      FontCache.get_font_css_url('Open Sans'))
Пример #6
0
 def test_should_ignore_not_a_list(self):
     fontcache = FontCache()
     self.assertEqual([], fontcache.get_backends())
Пример #7
0
 def test_should_return_list_of_installed_backends(self):
     fontcache = FontCache()
     self.assertIn(
         GoogleFontsBackend,
         [backend.__class__ for backend in fontcache.get_backends()])
Пример #8
0
 def test_should_return_slugified_font_name(self):
     self.assertEqual('open-sans',
                      FontCache.get_unique_font_name('Open Sans'))
Пример #9
0
 def handle(self, *args, **options):
     """
     Run command.
     """
     fontcache = FontCache()
     fontcache.clear(verbose=True)