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
This commit is contained in:
Vassilii Khachaturov 2013-06-20 09:39:03 +00:00
parent 7d96ee1308
commit dadd00f200

View File

@ -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