Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Desenho.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-07-26 13:37:30 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-08-10 13:49:30 (GMT)
commit234a272540e55443326dd87e5071e3c19bd3bbe9 (patch)
tree3d09f7a7560e2a6d24141f37bf786b3af3c2f028 /Desenho.py
parentf0b65094cb6ced412a85c6645a606fd8980426c9 (diff)
Text tool ported to cairo
This patch reorganize a little the text management code, to do the font_properties private to Area. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'Desenho.py')
-rw-r--r--Desenho.py37
1 files changed, 24 insertions, 13 deletions
diff --git a/Desenho.py b/Desenho.py
index cdcc674..19f561d 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -70,6 +70,7 @@ import math
import gc
import gobject
import cairo
+import pangocairo
RESIZE_DELAY = 500 # The time to wait for the resize operation to be
# executed, after the resize controls are pressed.
@@ -558,22 +559,32 @@ class Desenho:
else:
widget.text_in_progress = False
- try:
- # This works for a gtk.Entry
- text = widget.activity.textview.get_text()
- except AttributeError:
- # This works for a gtk.TextView
- buf = widget.activity.textview.get_buffer()
- start, end = buf.get_bounds()
- text = buf.get_text(start, end)
+ buf = widget.activity.textview.get_buffer()
+ start, end = buf.get_bounds()
+ text = buf.get_text(start, end)
+
+ textview = widget.activity.textview
+ tv_layout = textview.create_pango_layout(text)
+
+ ctx = widget.drawing_ctx
+
+ ctx.save()
+ ctx.new_path()
+ pango_context = pangocairo.CairoContext(ctx)
+ pango_context.set_source_rgba(*widget.tool['cairo_stroke_color'])
+
+ pango_layout = pango_context.create_layout()
+ pango_layout.set_font_description(widget.get_font_description())
+ pango_layout.set_text(unicode(text))
- layout = widget.activity.textview.create_pango_layout(text)
+ tv_alloc = textview.get_allocation()
+ pango_context.move_to(tv_alloc.x, tv_alloc.y)
+ pango_context.show_layout(pango_layout)
+ ctx.stroke()
+ ctx.restore()
- widget.pixmap.draw_layout(widget.gc_brush,
- widget.oldx, widget.oldy, layout)
- widget.pixmap_temp.draw_layout(widget.gc,
- widget.oldx, widget.oldy, layout)
widget.activity.textview.hide()
+ widget.drawing_canvas.flush()
try:
widget.activity.textview.set_text('')