OSDN Git Service

Glyph widths are treated as double.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 29 Apr 2009 09:48:35 +0000 (18:48 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 29 Apr 2009 09:48:35 +0000 (18:48 +0900)
src/FukuiNoNamari/thread_view.py

index 4ab136f..a6ff9cd 100644 (file)
@@ -30,6 +30,14 @@ def get_approximate_char_height(pango_context):
     return log[3] / pango.SCALE + 2
 
 
+class Rectangle:
+    def __init__(self, x, y, width, height):
+        self.x = x
+        self.y = y
+        self.width = width
+        self.height = height
+
+
 class Line:
 
     HEIGHT = 15
@@ -71,7 +79,7 @@ class ElementEmpty:
     def build_line_list(self, x, y, width, left_margin):
         self.initialize()
 
-        line = Line(0, 0, gtk.gdk.Rectangle(
+        line = Line(0, 0, Rectangle(
             x, y, width - x,
             get_approximate_char_height(self.pango_layout.get_context())))
         self.line_list.append(line)
@@ -142,7 +150,7 @@ class ElementText:
             if current_line_x + current_line_width + ch_w > width:
                 line = Line(
                     current_line_start_index, index,
-                    gtk.gdk.Rectangle(
+                    Rectangle(
                     current_line_x, current_line_y,
                     current_line_width, ch_h))
                 self.line_list.append(line)
@@ -156,7 +164,7 @@ class ElementText:
 
         if current_line_start_index < len(self.text):
             line = Line(current_line_start_index, len(self.text),
-                        gtk.gdk.Rectangle(current_line_x,
+                        Rectangle(current_line_x,
                                           current_line_y,
                                           current_line_width,
                                           ch_h))
@@ -224,7 +232,7 @@ class ElementText:
             pango_layout.set_text(u_text)
             pango_layout.set_attributes(attrs)
             drawingarea.window.draw_layout(
-                gc, line.rectangle.x, line.rectangle.y + y_offset,
+                gc, int(line.rectangle.x), line.rectangle.y + y_offset,
                 pango_layout)