diff --git a/src/ui/painter.rs b/src/ui/painter.rs index 90b221a..4cf983e 100644 --- a/src/ui/painter.rs +++ b/src/ui/painter.rs @@ -72,7 +72,7 @@ impl<'a> Painter<'a> { ctx.fill().unwrap(); // draw text - ctx.move_to(x + 0.2, y+0.8); + ctx.move_to(x + 0.2, y); ctx.theme_text(&input, false, &[], &self.theme); } @@ -90,9 +90,9 @@ impl<'a> Painter<'a> { ctx.fill().unwrap(); // draw text - ctx.move_to (x+0.2, y+0.8); + ctx.move_to (x+0.2, y); ctx.theme_text(&source, selected, &[], &self.theme); - ctx.move_to (x+3.5, y+0.8); + ctx.move_to (x+3.5, y); ctx.theme_text(&result, selected, indices, &self.theme); } diff --git a/src/ui/theme.rs b/src/ui/theme.rs index adfc9e6..098b33c 100644 --- a/src/ui/theme.rs +++ b/src/ui/theme.rs @@ -125,10 +125,21 @@ impl ThemedContextExt for cairo::Context { font.set_size(theme.font.1*pango::SCALE); layout.set_font_description(Some(&font)); + layout.set_spacing(0); + layout.set_text(text); let (_width,height) = layout.size(); - self.rel_move_to(0.0, -(height as f64)/(pango::SCALE as f64)); + let device_height = (height as f64)/(pango::SCALE as f64); + + self.save().unwrap(); + self.scale(30.0,30.0); + let cairo_user_height = self.device_to_user_point(device_height); + let offset = (1.0 - cairo_user_height) / 2.0; + self.rel_move_to(0.0, offset); + self.restore().unwrap(); + + pangocairo::update_layout(self, &layout); pangocairo::show_layout(self, &layout); self.restore().unwrap(); }