diff --git a/lib/beautiful.lua.in b/lib/beautiful.lua.in index 8b7ddd5a..cf512fd1 100644 --- a/lib/beautiful.lua.in +++ b/lib/beautiful.lua.in @@ -44,9 +44,8 @@ local function load_font(name) -- load new font local desc = Pango.FontDescription.from_string(name) - -- Create a temporary surface that we need for computing the size :( - local surface = cairo.ImageSurface(cairo.Format.ARGB32, 1, 1) - local layout = PangoCairo.create_layout(cairo.Context(surface)) + local ctx = PangoCairo.font_map_get_default():create_context() + local layout = Pango.Layout.new(ctx) layout:set_font_description(desc) local width, height = layout:get_pixel_size() diff --git a/lib/wibox/widget/textbox.lua.in b/lib/wibox/widget/textbox.lua.in index e33bd4b7..b09987f6 100644 --- a/lib/wibox/widget/textbox.lua.in +++ b/lib/wibox/widget/textbox.lua.in @@ -48,13 +48,6 @@ function fit(box, width, height) return logical.width, logical.height end --- Return a pango layout which can be used if no cairo context is available -local function get_temp_layout() - local surface = cairo.ImageSurface(cairo.Format.ARGB32, 0, 0) - local cr = cairo.Context(surface) - return PangoCairo.create_layout(cr) -end - --- Set a textbox' text. -- @param text The text to set. This can contain pango markup (e.g. bold) function set_markup(box, text) @@ -131,8 +124,9 @@ local function new() end end - -- Spot the hack: Temporary surface to make pango happy - ret._layout = get_temp_layout() + local ctx = PangoCairo.font_map_get_default():create_context() + ret._layout = Pango.Layout.new(ctx) + ret:set_ellipsize("end") ret:set_wrap("word_char") ret:set_valign("center")