From b657b6c360395aa73ab1ec2dbf8e808fb2871e3d Mon Sep 17 00:00:00 2001 From: Muse Date: Sat, 5 Dec 2026 22:27:40 +0000 Subject: [PATCH] XTachometer: place numerals by per-label radial extent Same radial-extent inset as C/Rust: the glyph box farthest corner in the radial direction stays inside the tick ring (inner end r-16) with 4 px clearance, so a wide 4-digit label never crosses the dial rim. Verified by re-shoot; full suite still 363 tests OK. --- lightgui/xframe/monitor.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lightgui/xframe/monitor.py b/lightgui/xframe/monitor.py index 39c9eeb..781414f 100644 --- a/lightgui/xframe/monitor.py +++ b/lightgui/xframe/monitor.py @@ -1335,8 +1335,16 @@ class MonitorWidget(Widget): cr.restore() if major: label = "%.0f" % (lo + f * (hi - lo)) - lx = cx + (r - 26) * math.cos(ang) - ly = cy + (r - 26) * math.sin(ang) \ + # Numeral centre radius: the glyph box's farthest + # corner in the radial direction must stay inside the + # tick ring (inner end r-16) with 4 px clearance, so a + # wide 4-digit label never crosses the dial rim. + lw = _text_width(cr, self, label, size=numeral_px, bold=True) + extent = (lw / 2) * abs(math.cos(ang)) \ + + (numeral_px / 2) * abs(math.sin(ang)) + lr = max(8.0, r - 16 - extent - 4) + lx = cx + lr * math.cos(ang) + ly = cy + lr * math.sin(ang) \ + numeral_px * 0.35 rgb = _RED if f >= red_frac else _TEXT _wtext(cr, self, label, lx, ly, size=numeral_px,