Description
When a cell in the log view (or the filter view) enters edit mode – via double-click or Ctrl+E, e.g. to select and copy part of a line – the text switches from the configured font to Courier New 8.25pt. After leaving edit mode the configured font is shown again.
This is point 2 of #565, which is still reproducible on current Development (1637c2b). PR #579 (#573) fixed font handling in general but did not touch this code path.
Steps to reproduce
- Settings → choose any font other than Courier New (e.g. Consolas 10pt)
- Open a log file
- Double-click a line (or press Ctrl+E)
Expected: the edit control uses the configured font
Actual: the edit control uses Courier New 8.25pt
Root cause
- The grid content is painted manually (
PaintHighlightedCell → TextRenderer.DrawText) using NormalFont, so the display is correct.
- The editing control (
LogCellEditingControl) is not painted manually; it takes its font from the inherited cell style.
LogWindow.PreferencesChanged only sets dataGridView.DefaultCellStyle.Font / filterGridView.DefaultCellStyle.Font.
LogWindow.CreateDefaultViewStyle assigns RowsDefaultCellStyle = PaintHelper.GetDataGridDefaultRowStyle(darkMode), which hardcodes new Font("Courier New", 8.25F, ...).
- In the DataGridView style inheritance,
RowsDefaultCellStyle takes precedence over DefaultCellStyle, so the editing control always ends up with Courier New 8.25pt.
Proposed fix
Keep RowsDefaultCellStyle.Font in sync with the configured font in LogWindow.PreferencesChanged:
dataGridView.DefaultCellStyle.Font = NormalFont;
filterGridView.DefaultCellStyle.Font = NormalFont;
// RowsDefaultCellStyle has precedence over DefaultCellStyle; the cell editing control
// (double-click / Ctrl+E) inherits its font from there, so keep both in sync.
dataGridView.RowsDefaultCellStyle.Font = NormalFont;
filterGridView.RowsDefaultCellStyle.Font = NormalFont;
Tested locally: the edit control now uses the configured font in both the log view and the filter view, also after changing the font in the settings at runtime.
Alternatively (or additionally), the hardcoded Font could be removed from PaintHelper.GetDataGridDefaultRowStyle so the row style inherits from DefaultCellStyle (see also the existing TODO there referencing #85).
Description
When a cell in the log view (or the filter view) enters edit mode – via double-click or Ctrl+E, e.g. to select and copy part of a line – the text switches from the configured font to Courier New 8.25pt. After leaving edit mode the configured font is shown again.
This is point 2 of #565, which is still reproducible on current
Development(1637c2b). PR #579 (#573) fixed font handling in general but did not touch this code path.Steps to reproduce
Expected: the edit control uses the configured font
Actual: the edit control uses Courier New 8.25pt
Root cause
PaintHighlightedCell→TextRenderer.DrawText) usingNormalFont, so the display is correct.LogCellEditingControl) is not painted manually; it takes its font from the inherited cell style.LogWindow.PreferencesChangedonly setsdataGridView.DefaultCellStyle.Font/filterGridView.DefaultCellStyle.Font.LogWindow.CreateDefaultViewStyleassignsRowsDefaultCellStyle = PaintHelper.GetDataGridDefaultRowStyle(darkMode), which hardcodesnew Font("Courier New", 8.25F, ...).RowsDefaultCellStyletakes precedence overDefaultCellStyle, so the editing control always ends up with Courier New 8.25pt.Proposed fix
Keep
RowsDefaultCellStyle.Fontin sync with the configured font inLogWindow.PreferencesChanged:Tested locally: the edit control now uses the configured font in both the log view and the filter view, also after changing the font in the settings at runtime.
Alternatively (or additionally), the hardcoded
Fontcould be removed fromPaintHelper.GetDataGridDefaultRowStyleso the row style inherits fromDefaultCellStyle(see also the existing TODO there referencing #85).