diff --git a/libs/canvas/ruler.cc b/libs/canvas/ruler.cc index 98e51a3705..387705310e 100644 --- a/libs/canvas/ruler.cc +++ b/libs/canvas/ruler.cc @@ -161,6 +161,7 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const Glib::RefPtr layout = Pango::Layout::create (cr); Pango::FontDescription* last_font_description = 0; + Coord prev = -1; for (vector::const_iterator m = marks.begin(); m != marks.end(); ++m) { Duple pos; @@ -169,6 +170,33 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const pos.x = floor ((m->position - _lower) / _metric->units_per_pixel); pos.y = self.y1; /* bottom edge */ + if (fd != last_font_description) { + layout->set_font_description (*fd); + last_font_description = fd; + } + + /* and the text */ + + if (!m->label.empty()) { + Pango::Rectangle logical; + + layout->set_text (m->label); + logical = layout->get_pixel_logical_extents (); + + if ((prev >= 0.) && ((pos.x - prev) < (6. + logical.get_width()))) { + continue; + } + + if (_divide_height >= 0) { + cr->move_to (pos.x + 2.0, self.y0 + _divide_height + logical.get_y() + 2.0); /* 2 pixel padding below divider */ + } else { + cr->move_to (pos.x + 2.0, self.y0 + logical.get_y() + .5 * (height - logical.get_height())); + } + + layout->show_in_cairo_context (cr); + prev = pos.x; + } + if (_outline_width == 1.0) { /* Cairo single pixel line correction */ cr->move_to (pos.x + 0.5, pos.y); @@ -194,31 +222,11 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const cr->rel_line_to (0, -height/5.0); break; } + cr->stroke (); - - if (fd != last_font_description) { - layout->set_font_description (*fd); - last_font_description = fd; - } - - /* and the text */ - - if (!m->label.empty()) { - Pango::Rectangle logical; - - layout->set_text (m->label); - logical = layout->get_pixel_logical_extents (); - - if (_divide_height >= 0) { - cr->move_to (pos.x + 2.0, self.y0 + _divide_height + logical.get_y() + 2.0); /* 2 pixel padding below divider */ - } else { - cr->move_to (pos.x + 2.0, self.y0 + logical.get_y() + .5 * (height - logical.get_height())); - } - layout->show_in_cairo_context (cr); - } } } - + if (_divide_height >= 0.0) { cr->set_line_width (1.0);