Пример #1
0
    def parse_html_into_style_data(self):
        """
        Parses HTML styled string text into a format more useful for styling pygame.font rendered text.
        """
        parser = TextHTMLParser(self.ui_theme, self.element_ids,
                                self.object_ids)
        parser.push_style('body', {"bg_color": self.background_colour})
        parser.feed(self.html_text)

        self.formatted_text_block = TextBlock(parser.text_data,
                                              self.text_wrap_rect,
                                              parser.indexed_styles,
                                              self.font_dict, self.link_style,
                                              self.background_colour,
                                              self.wrap_to_height)
Пример #2
0
 def test_weird_html(self, _init_pygame):
     theme = UIAppearanceTheme()
     parser = TextHTMLParser(theme, [], [])
     parser.feed(
         '<body bgcolor="" > <font size="" face="" >text</font></body>')
Пример #3
0
 def test_body_gradient(self, _init_pygame):
     theme = UIAppearanceTheme()
     parser = TextHTMLParser(theme, [], [])
     parser.feed('<body bgcolor=#FF0000,#FFFF00,0>text</body></body>')
Пример #4
0
 def test_invalid_tag(self, _init_pygame):
     theme = UIAppearanceTheme()
     parser = TextHTMLParser(theme, [], [])
     with pytest.warns(UserWarning, match='Unsupported HTML Tag'):
         parser.feed('</font><video>text</video>')
Пример #5
0
 def test_creation(self, _init_pygame):
     theme = UIAppearanceTheme()
     parser = TextHTMLParser(theme, [], [])
     parser.feed('<b>text</b>')
Пример #6
0
 def test_weird_html(self, _init_pygame):
     theme = UIAppearanceTheme(BlockingThreadedResourceLoader())
     parser = TextHTMLParser(theme, [])
     parser.feed('<body bgcolor="" > <font size="" face="" >text</font></body>')
Пример #7
0
 def test_body_gradient(self, _init_pygame):
     theme = UIAppearanceTheme(BlockingThreadedResourceLoader())
     parser = TextHTMLParser(theme, [])
     parser.feed('<body bgcolor=#FF0000,#FFFF00,0>text</body></body>')
Пример #8
0
 def test_creation(self, _init_pygame):
     theme = UIAppearanceTheme(BlockingThreadedResourceLoader())
     parser = TextHTMLParser(theme, [])
     parser.feed('<b>text</b>')