From dadd00f2003fe5113af0eef3c00e000edba4c8c8 Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Thu, 20 Jun 2013 09:39:03 +0000 Subject: [PATCH] 4571: RTL support missing in FanChart Partial fix, approved by bmcage. Fully RTL text will be rendered RTL, fully LTR will be LTR. Unfortunately, CTL (combination of the both) will still be broken. Better fix for bug# 4571 will be researched on trunk, in gtk3. svn: r22532 --- src/plugins/view/fanchartview.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/view/fanchartview.py b/src/plugins/view/fanchartview.py index 8884d7198..cb3ec9d06 100644 --- a/src/plugins/view/fanchartview.py +++ b/src/plugins/view/fanchartview.py @@ -345,13 +345,17 @@ class FanChartWidget(gtk.Widget): pos = start + ((stop - start) - self.text_degrees(text,radius))/2.0 + 90 x, y, w, h = self.allocation cr.save() - # Create a PangoLayout, set the font and text - # Draw the layout N_WORDS times in a circle - for i in range(len(text)): + l = len(text) + # A quick hack so it works at least in some RTL scenarios + # CTL text will still be broken, see bug# 4571 + ith_char_sector = (lambda i: l - i) if pango.find_base_dir(text, l) \ + == pango.DIRECTION_RTL \ + else lambda i: i + for i in range(l): cr.save() layout = self.create_pango_layout(text[i]) layout.set_font_description(pango.FontDescription("sans 8")) - angle = 360.0 * i / (radius * self.degrees_per_radius) + pos + angle = 360.0 * ith_char_sector(i) / (radius * self.degrees_per_radius) + pos cr.set_source_rgb(0, 0, 0) # black cr.rotate(angle * (math.pi / 180)); # Inform Pango to re-layout the text with the new transformation