diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 10:04:09 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 10:04:09 +0200 |
| commit | c9ff9b2f5434ff09b02a3ab33eada2d8721d242f (patch) | |
| tree | 7ed259f7ea48c1c22d4c740cdad1dc12d6b030e4 | |
| parent | 182f36b81e408569ec20d109ec558d2432403264 (diff) | |
| download | conky-theme-udt-c9ff9b2f5434ff09b02a3ab33eada2d8721d242f.tar.gz conky-theme-udt-c9ff9b2f5434ff09b02a3ab33eada2d8721d242f.zip | |
feat: give the clock its own font
Installs Oswald (OFL-1.1, from googlefonts/OswaldFont) under
~/.fonts/o/Oswald with its license, and points the clock numerals at it
for the squared look the rounded Noto Sans Black did not have.
Per-widget fonts needed no new machinery: card.font() already takes any
family string, so FONT_* are shared defaults rather than a restriction.
FONT_CLOCK joins them, and the weather card keeps FONT_HEAVY, so the two
no longer have to agree.
Cairo still cannot ask for a weight above bold, so a heavier cut is
selected by family name as FONT_HEAVY already did. Worth knowing that
fontconfig substitutes a default for a family it does not recognise,
which is indistinguishable from the font not applying; fc-match tells
you which happened.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | lib/card.lua | 12 | ||||
| -rw-r--r-- | widgets/clock.lua | 2 |
3 files changed, 24 insertions, 2 deletions
@@ -206,7 +206,17 @@ to Lua either. What Lua does get is `conky_config`, the config file's path, so `dashboard.lua` opens that file and parses the hex out of it. **Cairo has no Black font weight.** `CAIRO_FONT_WEIGHT_BOLD` is the maximum, so -the heavy clock numerals ask for the family `Noto Sans Black` at normal weight. +a heavier cut is selected by the family name fontconfig registers for it, e.g. +`Noto Sans Black` or `Oswald SemiBold` at normal weight, rather than by asking +for bold. + +**Fonts are per-widget when a widget wants one.** `lib/card.lua` holds the +shared `FONT_*` families, but `card.font()` takes any family string, so a +widget passes its own. The clock uses `FONT_CLOCK` (Oswald, OFL-1.1, under +`~/.fonts/o/Oswald`) for squared numerals while the weather card keeps +`FONT_HEAVY`. Check a new family with `fc-match` first: fontconfig silently +substitutes a default for a name it does not know, which looks exactly like the +font "not applying". **Sensors are globbed by hwmon `name`, never by index.** Indices drift across kernel and hardware reorders, and a stale one silently reports a different chip. diff --git a/lib/card.lua b/lib/card.lua index 4d94465..3352c4b 100644 --- a/lib/card.lua +++ b/lib/card.lua @@ -13,6 +13,18 @@ M.FONT_MONO = 'Inconsolata Nerd Font' M.FONT_UI = 'Noto Sans' M.FONT_HEAVY = 'Noto Sans Black' +-- Shared defaults, not a restriction: card.font() takes any family string, so +-- a widget wanting its own face just passes one. The clock does, for squared +-- numerals (Oswald, OFL-1.1, installed under ~/.fonts/o/Oswald). +-- +-- Cairo can only ask for Regular or Bold by weight, so a heavier cut is +-- selected by the family name fontconfig registers for it, exactly as +-- FONT_HEAVY does above: 'Oswald SemiBold' at NORMAL weight, not 'Oswald' at +-- bold. Fontconfig silently substitutes a default for a family it does not +-- know, which looks identical to the font "not applying", so check a new name +-- with `fc-match` before trusting it. +M.FONT_CLOCK = 'Oswald' + function M.font(cr, family, size, bold) cairo_select_font_face(cr, family, CAIRO_FONT_SLANT_NORMAL, bold and CAIRO_FONT_WEIGHT_BOLD or CAIRO_FONT_WEIGHT_NORMAL) diff --git a/widgets/clock.lua b/widgets/clock.lua index c3e9712..b7c80d9 100644 --- a/widgets/clock.lua +++ b/widgets/clock.lua @@ -33,7 +33,7 @@ function M.draw(cr, rect, colors) local avail = (bottom - date_band) - inner.y local size = math.min(avail * 0.46, inner.w * 0.95) - card.font(cr, card.FONT_HEAVY, size, false) + card.font(cr, card.FONT_CLOCK, size, true) card.rgba(cr, colors.body) -- Baselines. Cairo's y is the baseline, so the first sits one cap-height |
