diff --git a/libs/canvas/canvas/ruler.h b/libs/canvas/canvas/ruler.h index 287df437fb..c5980b6f04 100644 --- a/libs/canvas/canvas/ruler.h +++ b/libs/canvas/canvas/ruler.h @@ -67,6 +67,7 @@ public: void set_range (double lower, double upper); void set_font_description (Pango::FontDescription); + void set_second_font_description (Pango::FontDescription); void set_metric (const Metric&); void render (Rect const & area, Cairo::RefPtr) const; @@ -85,6 +86,7 @@ private: Gtkmm2ext::Color _divider_color_bottom; Pango::FontDescription* _font_description; + Pango::FontDescription* _second_font_description; mutable std::vector marks; mutable bool _need_marks; }; diff --git a/libs/canvas/ruler.cc b/libs/canvas/ruler.cc index 3b807b164e..e57ac5629f 100644 --- a/libs/canvas/ruler.cc +++ b/libs/canvas/ruler.cc @@ -38,6 +38,7 @@ Ruler::Ruler (Canvas* c, const Metric& m) , _upper (0) , _divide_height (-1.0) , _font_description (0) + , _second_font_description (0) , _need_marks (true) { } @@ -49,6 +50,7 @@ Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r) , _upper (0) , _divide_height (-1.0) , _font_description (0) + , _second_font_description (0) , _need_marks (true) { } @@ -60,6 +62,7 @@ Ruler::Ruler (Item* parent, const Metric& m) , _upper (0) , _divide_height (-1.0) , _font_description (0) + , _second_font_description (0) , _need_marks (true) { } @@ -71,6 +74,7 @@ Ruler::Ruler (Item* parent, const Metric& m, Rect const& r) , _upper (0) , _divide_height (-1.0) , _font_description (0) + , _second_font_description (0) , _need_marks (true) { } @@ -94,6 +98,16 @@ Ruler::set_font_description (Pango::FontDescription fd) end_visual_change (); } +void +Ruler::set_second_font_description (Pango::FontDescription fd) +{ + begin_visual_change (); + delete _second_font_description; + _second_font_description = new Pango::FontDescription (fd); + end_visual_change (); +} + + void Ruler::render (Rect const & area, Cairo::RefPtr cr) const { @@ -144,12 +158,12 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const /* draw ticks + text */ Glib::RefPtr layout = Pango::Layout::create (cr); - if (_font_description) { - layout->set_font_description (*_font_description); - } + + Pango::FontDescription* last_font_description = 0; for (vector::const_iterator m = marks.begin(); m != marks.end(); ++m) { Duple pos; + Pango::FontDescription* fd = _font_description; pos.x = floor ((m->position - _lower) / _metric->units_per_pixel); pos.y = self.y1; /* bottom edge */ @@ -168,6 +182,9 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const } else { cr->rel_line_to (0, -height); } + if (_second_font_description) { + fd = _second_font_description; + } break; case Mark::Minor: cr->rel_line_to (0, -height/3.0); @@ -178,6 +195,11 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const } cr->stroke (); + if (fd != last_font_description) { + layout->set_font_description (*fd); + last_font_description = fd; + } + /* and the text */ if (!m->label.empty()) {