diff options
author | Walter Bender <walter@sugarlabs.org> | 2013-12-11 22:57:37 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2013-12-11 22:57:37 (GMT) |
commit | 1dcd9b9f2669610511cf389e5b0b1778948c7982 (patch) | |
tree | 49c5d7cafab79d487d5ac4b6089f91b06f09c59b /TurtleArt/tacanvas.py | |
parent | 68cb5b448753040aa49889e1fae9a09239a6acf2 (diff) |
Jorge Alberto Gómez López patch to fix SVG text wrap bug
Diffstat (limited to 'TurtleArt/tacanvas.py')
-rw-r--r-- | TurtleArt/tacanvas.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py index 4bac442..f37a3a4 100644 --- a/TurtleArt/tacanvas.py +++ b/TurtleArt/tacanvas.py @@ -305,10 +305,14 @@ class TurtleGraphics: ''' Draw text ''' def _draw_text(cr, label, x, y, size, width, scale, heading, rgb): + import textwrap + final_scale = int(size * scale) * pango.SCALE + label = str(label) + label = '\n'.join(textwrap.wrap(label, int(width / scale))) cc = pangocairo.CairoContext(cr) pl = cc.create_layout() fd = pango.FontDescription('Sans') - fd.set_size(int(size * scale) * pango.SCALE) + fd.set_size(final_scale) pl.set_font_description(fd) if isinstance(label, (str, unicode)): pl.set_text(label.replace('\0', ' ')) |