diff --git a/widgets/components/XTachometer/XTachometer.h b/widgets/components/XTachometer/XTachometer.h index bcc8728..7f14c0d 100644 --- a/widgets/components/XTachometer/XTachometer.h +++ b/widgets/components/XTachometer/XTachometer.h @@ -184,9 +184,16 @@ public: if (i % 2 == 0) { std::string lab = fmt0(max_ * f / 1000.0); - int lx = cx + (int)((r - 26) * std::cos(a)); - int ly = cy - (int)((r - 26) * std::sin(a)); int lw = xframe::font_text_width(numeral_font, lab); + // Numeral centre radius: the glyph box's farthest + // corner in the radial direction must stay inside the + // tick ring (inner end r-10) with 4 px clearance, so a + // wide label never crosses the dial rim. + double extent = (lw / 2.0) * std::fabs(std::cos(a)) + + (numeral_px / 2.0) * std::fabs(std::sin(a)); + double lr = std::max(8.0, r - 10.0 - extent - 4.0); + int lx = cx + (int)(lr * std::cos(a)); + int ly = cy - (int)(lr * std::sin(a)); // Numerals at/after the redline render in red. Srgb lab_color = (f >= red_frac) ? redline_color_ : Srgb{20, 20, 20}; xframe::draw_text_font(display_, window_, gc_, numeral_font,