summaryrefslogtreecommitdiff
path: root/libs/canvas/text.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-30 10:39:26 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-30 10:39:26 -0400
commit5974f4730bbf9335c532017ba842f36e052386bf (patch)
treef0deeba8a3671f90976280a2837f048bd12af898 /libs/canvas/text.cc
parent471570705d58ee88f852009fee18f51562c34292 (diff)
allow Canvas::Text to have outline drawn in a contrasting color (based on actual color)
Diffstat (limited to 'libs/canvas/text.cc')
-rw-r--r--libs/canvas/text.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/libs/canvas/text.cc b/libs/canvas/text.cc
index cfad375814..6fa1d30d31 100644
--- a/libs/canvas/text.cc
+++ b/libs/canvas/text.cc
@@ -41,6 +41,7 @@ Text::Text (Canvas* c)
, _need_redraw (false)
, _clamped_width (COORD_MAX)
{
+ _outline = false;
}
Text::Text (Item* parent)
@@ -53,6 +54,7 @@ Text::Text (Item* parent)
, _need_redraw (false)
, _clamped_width (COORD_MAX)
{
+ _outline = false;
}
Text::~Text ()
@@ -121,9 +123,17 @@ Text::_redraw (Glib::RefPtr<Pango::Layout> layout) const
/* and draw, in the appropriate color of course */
- set_source_rgba (img_context, _color);
-
- layout->show_in_cairo_context (img_context);
+ if (_outline) {
+ set_source_rgba (img_context, _outline_color);
+ layout->update_from_cairo_context (img_context);
+ pango_cairo_layout_path (img_context->cobj(), layout->gobj());
+ img_context->stroke_preserve ();
+ set_source_rgba (img_context, _color);
+ img_context->fill ();
+ } else {
+ set_source_rgba (img_context, _color);
+ layout->show_in_cairo_context (img_context);
+ }
/* text has now been rendered in _image and is ready for blit in
* ::render
@@ -211,6 +221,9 @@ Text::set_color (Color color)
begin_change ();
_color = color;
+ if (_outline) {
+ set_outline_color (contrasting_text_color (_color));
+ }
_need_redraw = true;
end_change ();