Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2013-02-23 23:05:36 (GMT)
committer Walter Bender <walter.bender@gmail.com>2013-02-23 23:05:36 (GMT)
commit9b2c89766b7e6e9ba900a14807d03e4a35b1c564 (patch)
tree0ee48b03cf430c73bde96ddd0fdeb8a30e7a7e2d
parent7d71ed21341443638245b964d2d79b5c54879dd8 (diff)
set textview attrs with thought attrs
-rw-r--r--src/TextThought.py44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/TextThought.py b/src/TextThought.py
index 0d927e5..5c04197 100644
--- a/src/TextThought.py
+++ b/src/TextThought.py
@@ -779,8 +779,48 @@ class TextThought (ResizableThought):
self.textview.set_size_request(w, h)
self._fixed.put(self.textview, x, y)
self.textview.set_justification(gtk.JUSTIFY_CENTER)
- self.textview.modify_font(
- pango.FontDescription(utils.default_font))
+
+ font, size = None, None
+ bold, italic, underline = False, False, False
+ # Get current attributes and set them here
+ it = self.attributes.get_iterator()
+ while (1):
+ r = it.range()
+ for x in it.get_attrs():
+ if x.type == pango.ATTR_WEIGHT and x.value == pango.WEIGHT_BOLD:
+ logging.debug('bold')
+ bold = True
+ elif x.type == pango.ATTR_STYLE and x.value == pango.STYLE_ITALIC:
+ logging.debug('italic')
+ italic = True
+ elif x.type == pango.ATTR_UNDERLINE and x.value == pango.UNDERLINE_SINGLE:
+ logging.debug('underline')
+ underline = True
+ elif x.type == pango.ATTR_FONT_DESC:
+ logging.debug(x.desc.to_string ())
+ font, size = x.desc.to_string ().split()
+ if not it.next():
+ break
+
+ if font is None:
+ font = 'Sans'
+ logging.debug('setting default font')
+ if size is None:
+ size = utils.default_font_size = 10
+ logging.debug('setting default size')
+ font_desc = pango.FontDescription(font)
+ font_desc.set_size(
+ int(int(size) * pango.SCALE * self._parent.scale_fac))
+ if bold:
+ font_desc.set_weight(pango.WEIGHT_BOLD)
+ if italic:
+ font_desc.set_style(pango.STYLE_ITALIC)
+ self.textview.modify_font(font_desc)
+
+ r, g, b = utils.gtk_to_cairo_color(self.foreground_color)
+ rgba = gtk.gdk.Color(int(65535 * r), int(65535 * g), int(65535 * b))
+ self.textview.modify_text(gtk.STATE_NORMAL, rgba)
+
self.textview.get_buffer().set_text(self.text)
self.textview.show()
if self._textview_handler is None: