Re-select OEM font into DC before every render pass

Relying on CS_OWNDC to retain the font between frames is fragile --
Delphi's Canvas infrastructure can deselect it during paint cycles.
Without the OEM font, ExtTextOut renders with SYSTEM_FONT (ANSI_CHARSET),
causing CP437 box-drawing glyphs to display as accented letters, cell
metrics to mismatch (lines clipped), and cursor position to drift.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Duensing 2026-03-02 19:23:22 -06:00
parent 78753a65d8
commit a9e25ec67f

View file

@ -1139,8 +1139,12 @@ begin
Exit; Exit;
end; end;
{ Render dirty rows directly to screen DC } { Render dirty rows directly to screen DC. Re-select the OEM font each }
{ frame because Delphi's Canvas infrastructure can deselect it from the }
{ CS_OWNDC between paint cycles. }
DC := GetDC(Handle); DC := GetDC(Handle);
SelectObject(DC, FPaintFont);
SetBkMode(DC, OPAQUE);
for Row := 0 to FRows - 1 do for Row := 0 to FRows - 1 do
begin begin
if FAllDirty or FDirtyRow[Row] then if FAllDirty or FDirtyRow[Row] then
@ -1321,6 +1325,8 @@ begin
{ Full repaint: render each row directly to screen } { Full repaint: render each row directly to screen }
FAllDirty := True; FAllDirty := True;
DC := Canvas.Handle; DC := Canvas.Handle;
SelectObject(DC, FPaintFont);
SetBkMode(DC, OPAQUE);
for Row := 0 to FRows - 1 do for Row := 0 to FRows - 1 do
begin begin