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.
This commit is contained in:
Muse committed 2026-12-05 22:27:40 +00:00
1 parent f93dbb8c84
commit b657b6c360
1 file changed
+10 -2
+10 -2
View File
@@ -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,