From 1552547f650a82487ac72615c8533fd25b4ffc39 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 13 Oct 2016 17:11:38 -0400 Subject: stop using gkd_pango_context_get() in ArdourCanvas::Canvas and require concrete instances to supply a Pango::Context; do this for GtkCanvas and Push2Canvas --- libs/surfaces/push2/canvas.cc | 27 +++++++++++++++++++++++++++ libs/surfaces/push2/canvas.h | 3 +++ 2 files changed, 30 insertions(+) (limited to 'libs/surfaces') diff --git a/libs/surfaces/push2/canvas.cc b/libs/surfaces/push2/canvas.cc index 52a8534f5e..6a8d046aa9 100644 --- a/libs/surfaces/push2/canvas.cc +++ b/libs/surfaces/push2/canvas.cc @@ -17,11 +17,15 @@ */ +#include + #include #include #include #include "pbd/compose.h" +#include "pbd/error.h" +#include "pbd/i18n.h" #include "ardour/debug.h" @@ -233,3 +237,26 @@ Push2Canvas::visible_area () const /* may need to get more sophisticated once we do scrolling */ return Rect (0, 0, 960, 160); } + +Glib::RefPtr +Push2Canvas::get_pango_context () +{ + if (!pango_context) { + PangoFontMap* map = pango_cairo_font_map_get_default (); + if (!map) { + error << _("Default Cairo font map is null!") << endmsg; + return Glib::RefPtr (); + } + + PangoContext* context = pango_font_map_create_context (map); + + if (!context) { + error << _("cannot create new PangoContext from cairo font map") << endmsg; + return Glib::RefPtr (); + } + + pango_context = Glib::wrap (context); + } + + return pango_context; +} diff --git a/libs/surfaces/push2/canvas.h b/libs/surfaces/push2/canvas.h index e3343e3296..fe419f44ba 100644 --- a/libs/surfaces/push2/canvas.h +++ b/libs/surfaces/push2/canvas.h @@ -69,6 +69,8 @@ class Push2Canvas : public ArdourCanvas::Canvas void pick_current_item (ArdourCanvas::Duple const &, int) {} bool get_mouse_position (ArdourCanvas::Duple&) const { return false; } + Glib::RefPtr get_pango_context (); + private: Push2& p2; int _cols; @@ -83,6 +85,7 @@ class Push2Canvas : public ArdourCanvas::Canvas Cairo::RefPtr frame_buffer; Cairo::RefPtr context; Cairo::RefPtr expose_region; + Glib::RefPtr pango_context; bool expose (); int blit_to_device_frame_buffer (); -- cgit v1.2.3