diff --git a/lib/beautiful.lua.in b/lib/beautiful.lua.in index 72afa294b..f912a3923 100644 --- a/lib/beautiful.lua.in +++ b/lib/beautiful.lua.in @@ -44,7 +44,14 @@ local function set_font(f) -- Create a temporary surface that we need for computing the size :( local surface = capi.oocairo.image_surface_create("argb32", 1, 1) local cr = capi.oocairo.context_create(surface) - local layout = capi.oopango.cairo.layout_create(cr) + local layout + -- Api breakage in oopango + if capi.oopango.cairo_layout_create then + layout = capi.oopango.cairo_layout_create(cr) + else + layout = capi.oopango.cairo.layout_create(cr) + end + layout:set_font_description(font) local width, height = layout:get_pixel_size() diff --git a/lib/wibox/widget/textbox.lua.in b/lib/wibox/widget/textbox.lua.in index dd5c753d4..a170e28b2 100644 --- a/lib/wibox/widget/textbox.lua.in +++ b/lib/wibox/widget/textbox.lua.in @@ -15,9 +15,26 @@ local pairs = pairs module("wibox.widget.textbox") +local function layout_create(cr) + if oopango.cairo_layout_create then + return oopango.cairo_layout_create(cr) + end + return oopango.cairo.layout_create(cr) +end + +local function update_and_show(cr, layout) + if oopango.cairo_update_layout then + oopango.cairo_update_layout(cr, layout) + oopango.cairo_show_layout(cr, layout) + else + oopango.cairo.update_layout(cr, layout) + oopango.cairo.show_layout(cr, layout) + end +end + -- Setup a pango layout for the given textbox and cairo context local function setup_layout(box, cr, width, height) - local layout = oopango.cairo.layout_create(cr) + local layout = layout_create(cr) layout:set_ellipsize(box.ellipsize) layout:set_wrap(box.wrap) layout:set_width(oopango.units_from_number(width)) @@ -82,8 +99,7 @@ function draw(box, wibox, cr, width, height) local layout = setup_layout(box, cr, width, height) - oopango.cairo.update_layout(cr, layout) - oopango.cairo.show_layout(cr, layout) + update_and_show(cr, layout) end --- Fit the given textbox