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
This commit is contained in:
parent
4979bcf675
commit
3e8b12a533
|
@ -230,13 +230,6 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
||||||
tag.set_property('background-gdk', color)
|
tag.set_property('background-gdk', color)
|
||||||
tag.set_property('paragraph-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,
|
def __parse_length_frac_size_allocate(self, textview, allocation, frac,
|
||||||
callback, args):
|
callback, args):
|
||||||
callback(allocation.width*frac, *args)
|
callback(allocation.width*frac, *args)
|
||||||
|
@ -338,30 +331,19 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
||||||
|
|
||||||
def _parse_style_font_size(self, tag, value):
|
def _parse_style_font_size(self, tag, value):
|
||||||
try:
|
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 = {
|
scale = {
|
||||||
#'xx-small': Pango.SCALE_XX_SMALL,
|
'xx-small': 0.5787037037037,
|
||||||
#'x-small': Pango.SCALE_X_SMALL,
|
'x-small': 0.6444444444444,
|
||||||
#'small': Pango.SCALE_SMALL,
|
'small': 0.8333333333333,
|
||||||
#'medium': Pango.SCALE_MEDIUM,
|
'medium': 1.0,
|
||||||
#'large': Pango.SCALE_LARGE,
|
'large': 1.2,
|
||||||
#'x-large': Pango.SCALE_X_LARGE,
|
'x-large': 1.4399999999999,
|
||||||
#'xx-large': Pango.SCALE_XX_LARGE,
|
'xx-large': 1.728,
|
||||||
'xx-small': 0.5787037037037,
|
}[value]
|
||||||
'x-small': 0.6444444444444,
|
|
||||||
'small': 0.8333333333333,
|
|
||||||
'medium': 1.0,
|
|
||||||
'large': 1.2,
|
|
||||||
'x-large': 1.4399999999999,
|
|
||||||
'xx-large': 1.728,
|
|
||||||
}[value]
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
attrs = self._get_current_attributes()
|
tag.set_property('scale', scale)
|
||||||
if attrs.font_scale == 0:
|
|
||||||
tag.set_property('scale', scale)
|
|
||||||
return
|
return
|
||||||
if value == 'smaller':
|
if value == 'smaller':
|
||||||
tag.set_property('scale', 0.8333333333333)
|
tag.set_property('scale', 0.8333333333333)
|
||||||
|
|
|
@ -19,6 +19,10 @@ app.interface = Interface()
|
||||||
|
|
||||||
|
|
||||||
XHTML = [
|
XHTML = [
|
||||||
|
'''
|
||||||
|
<body xmlns='http://www.w3.org/1999/xhtml'><p><span style='font-size: xx-large;'>rexxnor: i nimes chum a...</span></p></body>
|
||||||
|
''',
|
||||||
|
|
||||||
'''
|
'''
|
||||||
<div>
|
<div>
|
||||||
<span style="color: red; text-decoration:underline">Hello</span>
|
<span style="color: red; text-decoration:underline">Hello</span>
|
||||||
|
|
Loading…
Reference in New Issue