From f87985115d5b206028bb5f9fd684cef57ea7211d Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Thu, 21 Dec 2023 10:10:36 +0100 Subject: [PATCH] view_{clock,day}: fix display bug when numbers change --- tile.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tile.lua b/tile.lua index d9dce56..9f83341 100644 --- a/tile.lua +++ b/tile.lua @@ -413,6 +413,13 @@ local function view_clock(starts, ends, config, x1, y1, x2, y2) if animate then a.draw(now, x1, y1, x2, y2) else + x = 0 + w = font_clock:width(clock, font_size) + if align == "right" then + x = a.width - w + elseif align == "center" then + x = (a.width - w) / 2 + end font_clock:write(x1+x, y1, clock, font_size, r,g,b,1) end end @@ -449,6 +456,14 @@ local function view_day(starts, ends, config, x1, y1, x2, y2) if animate then a.draw(now, x1, y1, x2, y2) else + x = 0 + line = string.format(template, day) + w = font_day:width(line, font_size) + if align == "right" then + x = a.width - w + elseif align == "center" then + x = (a.width - w) / 2 + end font_day:write(x1+x, y1, line, font_size, r,g,b,1) end end