beautiful.load_font: handle font height of 0 (#1782)

This might happen if no fonts are installed.  It now falls back to the
size from the font description.
This commit is contained in:
Daniel Hahler 2017-05-14 20:14:18 +02:00 committed by GitHub
parent 52fa619506
commit c9bfd934e7
1 changed files with 6 additions and 0 deletions

View File

@ -124,6 +124,12 @@ local function load_font(name)
-- Calculate font height.
local metrics = ctx:get_metrics(desc, nil)
local height = math.ceil((metrics:get_ascent() + metrics:get_descent()) / Pango.SCALE)
if height == 0 then
height = desc:get_size() / Pango.SCALE
gears_debug.print_warning(string.format(
"beautiful.load_font: could not get height for '%s' (likely missing font), using %d.",
name, height))
end
local font = { name = name, description = desc, height = height }
fonts[name] = font