aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/clock.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/widgets/clock.lua b/widgets/clock.lua
index b7c80d9..01f6012 100644
--- a/widgets/clock.lua
+++ b/widgets/clock.lua
@@ -43,8 +43,15 @@ function M.draw(cr, rect, colors)
-- Tight leading, as in the mockup: the numerals nearly touch.
local y2 = y1 + size * 0.92
- card.text(cr, x, y1, os.date('%H'))
- card.text(cr, x, y2, os.date('%M'))
+ -- Centred horizontally: measure(), not advance(), because ink width is what
+ -- centring wants. Oswald is condensed, so '10' and '03' differ in width and
+ -- each line is centred on its own measurement rather than a shared one.
+ local function centred(s, baseline)
+ local w = card.measure(cr, s)
+ card.text(cr, inner.x + (inner.w - w) / 2, baseline, s)
+ end
+ centred(os.date('%H'), y1)
+ centred(os.date('%M'), y2)
-- Weekday and date sit against the bottom edge, not at a fixed drop from the
-- numerals. That is what puts the slack of a tall cell in the middle of the