From 3049f919a30eb78549718bdef1cdac7ecd1a65c4 Mon Sep 17 00:00:00 2001 From: Uladzimir Karpenka Date: Thu, 2 Jul 2026 13:26:12 +0300 Subject: [PATCH] fix(slices): center badge letter via widgetset TextRect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Manual TextWidth/TextHeight centering pushed the glyph up-left on the substituted monospace font (Linux). Let the widgetset center it with a taCenter/tlCenter TTextStyle, fixing the A/×/SPLIT/TX badges. Co-Authored-By: Claude Opus 4.8 --- VfoOverlay.pas | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/VfoOverlay.pas b/VfoOverlay.pas index 7b3e348..49bd2be 100644 --- a/VfoOverlay.pas +++ b/VfoOverlay.pas @@ -592,6 +592,8 @@ end; procedure TVfoOverlay.DrawBadge(C: TCanvas; const R: TRect; const Lbl: string; BgColor, TxtColor: TColor); +var + TS: TTextStyle; begin C.Brush.Color := BgColor; C.Brush.Style := bsSolid; @@ -603,8 +605,14 @@ begin C.Font.Style := [fsBold]; C.Font.Color := TxtColor; C.Brush.Style := bsClear; - C.TextOut(R.Left + (R.Right - R.Left - C.TextWidth(Lbl)) div 2, - R.Top + (R.Bottom - R.Top - C.TextHeight('A')) div 2, Lbl); + // Центровку доверяем виджетсету (TextRect со стилем) — ручной расчёт по + // TextWidth/Height на подменном шрифте уводил глиф влево-вверх. + FillChar(TS, SizeOf(TS), 0); + TS.Alignment := taCenter; + TS.Layout := tlCenter; + TS.SingleLine := True; + TS.Clipping := True; + C.TextRect(R, R.Left, R.Top, Lbl, TS); end; procedure TVfoOverlay.DrawSpeaker(C: TCanvas; X, Y: Integer; Muted: Boolean);