Skip to content

Use the correct font for subtitle grid column width measurements#11575

Merged
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/subtitle-grid-ui-font
Jun 13, 2026
Merged

Use the correct font for subtitle grid column width measurements#11575
niksedk merged 1 commit into
SubtitleEdit:mainfrom
mjuhasz:fix/subtitle-grid-ui-font

Conversation

@mjuhasz

@mjuhasz mjuhasz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

This PR makes sure that auto-sized subtitle grid columns get their width based on the correct font so the inexplicably large white space after the Show and Hide columns is gone.

It was a subtitle grid font-scoping issue where changing the subtitle text font could widen the Show / Hide columns even though those columns were still rendered with the UI font. You can see this in the video below: changing the subtitle text font changes the width of the Show and Hide columns, for no reason.

Font.change.mov

Problem

The main subtitle DataGrid was assigning SubtitleTextBoxAndGridFontName to the grid itself.

That caused two different behaviors:

  • The visible Show / Hide cells still rendered with the UI font because they are plain TextBlocks and the app-level UI font style applies directly to TextBlock.
  • The Show / Hide column auto-fit logic measured width from SubtitleGrid.FontFamily, so switching to a wider subtitle font such as SF Mono produced wider timing columns.

Result: the rendered cells looked correct, but the measured widths were based on the wrong font.

Fix

  • Remove the grid-level subtitle font override from the main subtitle DataGrid
  • Keep the subtitle font scoped to subtitle text content only
  • Let timing and other non-text columns inherit the normal UI font for both rendering and auto-fit measurement

Result

  • Show / Hide widths no longer change when only the subtitle text font changes
  • Subtitle text and the subtitle editor still use the selected subtitle font
  • Non-text grid columns stay aligned with the UI font

Testing

  • Verified the following behavior manually:
    • changing subtitle font from Charter to SF Mono no longer changes Show / Hide column width
    • subtitle text still uses the selected subtitle font
    • timing columns continue to render with the UI font

The main subtitle DataGrid was assigning SubtitleTextBoxAndGridFontName to the grid itself. That setting was intended for subtitle text content, but it also changed the font family used by AutoFitColumns() when measuring the Show/Hide timing columns.

The visible Show/Hide cells still rendered with the UI font because they are plain TextBlocks and the app-level UI font style applies directly to TextBlock controls. Width measurement followed a different path: MeasureShowHideColumnWidth() read SubtitleGrid.FontFamily, so switching the subtitle font to a wider face such as SF Mono produced wider timing columns even though the rendered cells continued to look like the UI font.

Remove the grid-level font override and keep the subtitle font scoped to the subtitle text cells and editor controls. This makes Show/Hide and other non-text columns inherit the normal UI font for both rendering and auto-fit measurement, eliminating the extra whitespace while preserving the chosen subtitle font for subtitle text.
@niksedk niksedk merged commit 505d0d3 into SubtitleEdit:main Jun 13, 2026
2 checks passed
@mjuhasz mjuhasz deleted the fix/subtitle-grid-ui-font branch June 13, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants