Browse code

When positioning the text vertically, use the coordinate for the baseline rather than absolute bottom of the text. Unfortunately I couldn't figure out how to determine the descent of a font used by pango.Layout.

From: Marius Gedminas <marius@gedmin.as>

Jose.R.Fonseca authored on 13/07/2008 03:19:44
Showing 1 changed files

  • xdot.py index d383fdf..ff68e19 100755
... ...
@@ -129,6 +129,8 @@ class TextShape(Shape):
129 129
         width = float(width)/pango.SCALE
130 130
         height = float(height)/pango.SCALE
131 131
 
132
+        descent = 2 # XXX get descender from font metrics
133
+
132 134
         cr.move_to(self.x - self.w/2, self.y)
133 135
 
134 136
         if self.j == self.LEFT:
... ...
@@ -140,7 +142,7 @@ class TextShape(Shape):
140 142
         else:
141 143
             assert 0
142 144
 
143
-        y = self.y - height
145
+        y = self.y - height + descent
144 146
 
145 147
         cr.move_to(x, y)
146 148