aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-17 10:11:15 +0200
committerDanilo M. <danix@danix.xyz>2026-09-17 10:11:15 +0200
commitd4a2b43ea95ef6e32e78bea25f5336ea54ec92ee (patch)
treebc09dba141efdc656c38458913e17b781ce68ba8
parent4e133cddd6ef7735eee264f90a4b69e814c2dea7 (diff)
downloadconky-theme-udt-d4a2b43ea95ef6e32e78bea25f5336ea54ec92ee.tar.gz
conky-theme-udt-d4a2b43ea95ef6e32e78bea25f5336ea54ec92ee.zip
fix: close the gap between the clock numerals and the date
The numeral size was capped at a flat 0.46 of the available height, which for two baselines spanning 1.70x the size meant they could only ever fill about four fifths of the band, leaving a void above the date. The divisor is now derived from the baselines themselves. The width cap is measured rather than guessed: two Oswald digits are 1.00x the font size wide (at size 100, '00' measures 100.0px and the widest pair '88' 98.0px), so a width w permits a size of about w, less a margin at the card edges. A narrow cell is still width-bound and cannot fill its height. That slack is now split above and below the numerals instead of collecting under them, so the pair sits centred in the space it cannot fill. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
-rw-r--r--widgets/clock.lua28
1 files changed, 23 insertions, 5 deletions
diff --git a/widgets/clock.lua b/widgets/clock.lua
index 01f6012..ba8f37a 100644
--- a/widgets/clock.lua
+++ b/widgets/clock.lua
@@ -27,11 +27,29 @@ function M.draw(cr, rect, colors)
local date_size = clamp(inner.w * 0.050, 11, 24)
local date_band = day_size * 1.6 + date_size * 1.8
- -- Two stacked numerals fill the space above the date band. Whichever of
- -- height and width binds first wins, so a wide short cell is limited by its
- -- height and a narrow tall one by its width, and neither overflows.
+ -- Two stacked numerals fill the space above the date band.
+ --
+ -- The divisor is derived, not tuned: the first baseline sits at 0.78 of the
+ -- size (cap height) and the second a further 0.92 below it, so the pair
+ -- occupies size * 1.70. Dividing the available height by that is what makes
+ -- the numerals actually reach the date band instead of leaving a gap; the
+ -- earlier flat 0.46 left a fifth of the band empty.
+ --
+ -- Whichever of height and width binds first wins, so a wide short cell is
+ -- limited by its height and a narrow tall one by its width, and neither
+ -- overflows.
+ -- The width cap is the font's, measured rather than guessed: two Oswald
+ -- digits are 1.00x the font size wide (measured at size 100: '00' is 100.0px,
+ -- the widest pair '88' is 98.0px), so the size a width w permits is w itself,
+ -- less a little breathing room at the card edges.
local avail = (bottom - date_band) - inner.y
- local size = math.min(avail * 0.46, inner.w * 0.95)
+ local size = math.min(avail / 1.70, inner.w * 0.92)
+
+ -- A narrow tall cell is width-bound, which leaves the numerals floating well
+ -- above the date. Centre the pair in the space they cannot fill instead of
+ -- hanging them from the top, so the slack sits above and below them equally.
+ local slack = avail - size * 1.70
+ if slack < 0 then slack = 0 end
card.font(cr, card.FONT_CLOCK, size, true)
card.rgba(cr, colors.body)
@@ -39,7 +57,7 @@ function M.draw(cr, rect, colors)
-- Baselines. Cairo's y is the baseline, so the first sits one cap-height
-- down; 0.78 of the font size approximates cap height for Noto Sans and
-- avoids measuring every frame.
- local y1 = inner.y + size * 0.78
+ local y1 = inner.y + slack / 2 + size * 0.78
-- Tight leading, as in the mockup: the numerals nearly touch.
local y2 = y1 + size * 0.92