LoadDict(self.dict)
self.textstr = None
+
+ ctx = page.get_pango_context()
+ fd = ctx.get_font_description()
+ met = ctx.get_metrics(fd)
+ self.lineheight = (met.get_ascent() + met.get_descent()) / pango.SCALE
+ self.lineascent = met.get_ascent() / pango.SCALE
+
def close_application(self, widget):
self.save_page()
gtk.main_quit()
def draw_text(self, pos, colour, str, cursor = None):
layout = self.page.create_pango_layout(str)
- ctx = self.page.get_pango_context()
- ascent = ctx.get_metrics(ctx.get_font_description()).get_ascent()
- self.page.window.draw_layout(colour, pos[0], pos[1] - ascent/pango.SCALE,
+ self.page.window.draw_layout(colour, pos[0], pos[1] - self.lineascent,
layout)
if cursor != None:
(strong,weak) = layout.get_cursor_pos(cursor)
self.flush_text()
self.textcurs = 0
self.textstr = ""
- ctx = self.page.get_pango_context()
- ascent = ctx.get_metrics(ctx.get_font_description()).get_ascent()
- descent = ctx.get_metrics(ctx.get_font_description()).get_descent()
self.textpos = [ self.textpos[0], self.textpos[1] +
- (ascent + descent) / pango.SCALE ]
+ self.lineheight ]
else:
self.textstr = self.textstr[0:self.textcurs] + sym + \
self.textstr[self.textcurs:]