From 3e8b12a533da03db7af7cc6f4467398e7c7a6d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 16 Nov 2018 16:23:01 +0100 Subject: [PATCH] XHTML: Fix parsing font-size Remove checking for font_scale, Gtk.TextIter.get_attributes() seems buggy at the moment, and we dont need to check the current scale to apply a new scale Fixes #9067 --- gajim/htmltextview.py | 36 +++++++++--------------------------- test/gtk/htmltextview.py | 4 ++++ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/gajim/htmltextview.py b/gajim/htmltextview.py index ac8ce38ba..ef22227f1 100644 --- a/gajim/htmltextview.py +++ b/gajim/htmltextview.py @@ -230,13 +230,6 @@ class HtmlHandler(xml.sax.handler.ContentHandler): tag.set_property('background-gdk', color) tag.set_property('paragraph-background-gdk', color) - def _get_current_attributes(self): - attrs = self.textview.get_default_attributes() - self.iter.backward_char() - attrs = (self.iter.get_attributes())[1] - self.iter.forward_char() - return attrs - def __parse_length_frac_size_allocate(self, textview, allocation, frac, callback, args): callback(allocation.width*frac, *args) @@ -338,30 +331,19 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def _parse_style_font_size(self, tag, value): try: - # see http://developer.gnome.org/pango/stable/pango-Text-Attributes.html#PANGO-SCALE-XX-SMALL:CAPS - # http://consciouslyusing.blogspot.ru/2012/01/heads-up-missing-pango-text-scale.html scale = { - #'xx-small': Pango.SCALE_XX_SMALL, - #'x-small': Pango.SCALE_X_SMALL, - #'small': Pango.SCALE_SMALL, - #'medium': Pango.SCALE_MEDIUM, - #'large': Pango.SCALE_LARGE, - #'x-large': Pango.SCALE_X_LARGE, - #'xx-large': Pango.SCALE_XX_LARGE, - 'xx-small': 0.5787037037037, - 'x-small': 0.6444444444444, - 'small': 0.8333333333333, - 'medium': 1.0, - 'large': 1.2, - 'x-large': 1.4399999999999, - 'xx-large': 1.728, - }[value] + 'xx-small': 0.5787037037037, + 'x-small': 0.6444444444444, + 'small': 0.8333333333333, + 'medium': 1.0, + 'large': 1.2, + 'x-large': 1.4399999999999, + 'xx-large': 1.728, + }[value] except KeyError: pass else: - attrs = self._get_current_attributes() - if attrs.font_scale == 0: - tag.set_property('scale', scale) + tag.set_property('scale', scale) return if value == 'smaller': tag.set_property('scale', 0.8333333333333) diff --git a/test/gtk/htmltextview.py b/test/gtk/htmltextview.py index 6b296c779..48ecb0b3f 100644 --- a/test/gtk/htmltextview.py +++ b/test/gtk/htmltextview.py @@ -19,6 +19,10 @@ app.interface = Interface() XHTML = [ + ''' +

rexxnor: i nimes chum a...

+ ''', + '''
Hello