X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Futils.cc;h=9c1ef22a88c579ebcd38e08a3f24d270eeb0d538;hb=4b35fc4c68fbd4845f7f8f3d2307e97412d7a4d8;hp=1057773ae704195be8006686a13462f4ea885ca7;hpb=d6ef740e9002c7112bc47cb2d9d8d4b8609aa089;p=ardour.git diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 1057773ae7..9c1ef22a88 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -44,6 +44,20 @@ using namespace sigc; using namespace Glib; using namespace PBD; +int +pixel_width (const ustring& str, Pango::FontDescription& font) +{ + Label foo; + Glib::RefPtr layout = foo.create_pango_layout (""); + + layout->set_font_description (font); + layout->set_text (str); + + int width, height; + Gtkmm2ext::get_ink_pixel_size (layout, width, height); + return width; +} + ustring fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses) { @@ -119,7 +133,7 @@ xpm2rgb (const char** xpm, uint32_t& w, uint32_t& h) return 0; } - savergb = rgb = (unsigned char*)art_alloc (h * w * 3); + savergb = rgb = (unsigned char*) malloc (h * w * 3); // LOAD XPM COLORMAP LONG ENOUGH TO DO CONVERSION for (t = 0; t < colors; ++t) { @@ -162,7 +176,7 @@ xpm2rgba (const char** xpm, uint32_t& w, uint32_t& h) return 0; } - savergb = rgb = (unsigned char*)art_alloc (h * w * 4); + savergb = rgb = (unsigned char*) malloc (h * w * 4); // LOAD XPM COLORMAP LONG ENOUGH TO DO CONVERSION @@ -232,7 +246,21 @@ get_font_for_style (string widgetname) foobar.ensure_style(); style = foobar.get_style (); - return style->get_font(); + + Glib::RefPtr layout = foobar.get_layout(); + + PangoFontDescription *pfd = (PangoFontDescription *)pango_layout_get_font_description((PangoLayout *)layout->gobj()); + + if (!pfd) { + + /* layout inherited its font description from a PangoContext */ + + PangoContext* ctxt = (PangoContext*) pango_layout_get_context ((PangoLayout*) layout->gobj()); + pfd = pango_context_get_font_description (ctxt); + return Pango::FontDescription (pfd, true); /* make a copy */ + } + + return Pango::FontDescription (pfd, true); /* make a copy */ } uint32_t