Fix #3996: edit the display font size in points, not pixels - #3998
Conversation
The options dialog bound DisplaySettings.SelectedFontSize (device-independent pixels) straight into a NumericUpDown, so a fresh profile showed 13.33 and the 6-72 bounds were pixels. The WPF host presented points via FontSizeConverter; this restores that behavior on Avalonia with an editable size ComboBox (like the Windows font dialogs) backed by a pt/px proxy on the viewmodel. The stored value stays pixels so settings files keep round-tripping with ILSpy 9.x. Assisted-by: Claude:claude-fable-5:Claude Code
Code reviewVerified locally: Four things below. 1.
|
christophwille
left a comment
There was a problem hiding this comment.
Findings from the review inline below (summary is in the comment above).
…drift Review follow-ups on #3998: reject non-finite parses (NaN slips through Math.Clamp and, once persisted, permanently fails the editor's SelectedFontSize > 0 guard), commit the clamped value back into the box on focus loss (the echo suppression otherwise leaves a typed "3" on screen while 6 pt is stored), and assert the theme actually realizes PART_EditableTextBox instead of trusting the IsEditable property. The 4/3 pt/px ratio is documented as the WPF-host convention it is - exact on Windows/X11, deliberately not the Cocoa-point number on macOS - rather than a universal. Assisted-by: Claude:claude-fable-5:Claude Code
|
All four addressed in 1bcb33b; replies with details on each thread. Short version: NaN is rejected via |
…drift Review follow-ups on #3998: reject non-finite parses (NaN slips through Math.Clamp and, once persisted, permanently fails the editor's SelectedFontSize > 0 guard), commit the clamped value back into the box on focus loss (the echo suppression otherwise leaves a typed "3" on screen while 6 pt is stored), and assert the theme actually realizes PART_EditableTextBox instead of trusting the IsEditable property. The 4/3 pt/px ratio is documented as the WPF-host convention it is - exact on Windows/X11, deliberately not the Cocoa-point number on macOS - rather than a universal. Assisted-by: Claude:claude-fable-5:Claude Code
1bcb33b to
9fbebb8
Compare
|
The Ubuntu leg failed on the new |
…drift Review follow-ups on #3998: reject non-finite parses (NaN slips through Math.Clamp and, once persisted, permanently fails the editor's SelectedFontSize > 0 guard), commit the clamped value back into the box on focus loss (the echo suppression otherwise leaves a typed "3" on screen while 6 pt is stored), and assert the theme actually realizes PART_EditableTextBox instead of trusting the IsEditable property. The 4/3 pt/px ratio is documented as the WPF-host convention it is - exact on Windows/X11, deliberately not the Cocoa-point number on macOS - rather than a universal. Assisted-by: Claude:claude-fable-5:Claude Code
9fbebb8 to
6b0b49a
Compare
Fixes #3996.
The options dialog bound
DisplaySettings.SelectedFontSize(device-independent pixels) straight into aNumericUpDown, so a fresh profile showed13.333...instead of10, the increment stepped by 0.75 pt, and the 6-72 bounds were pixels (4.5-54 pt). The WPF host presented the value in points viaFontSizeConverter; this restores that behavior on Avalonia, matching the Windows font dialogs (Notepad et al.).What changed
ILSpy/Options/DisplaySettingsViewModel.cs- newSelectedFontSizePointsstring proxy that showsMath.Round(px * 3 / 4)and storespt * 4 / 3, mirroring the WPFFontSizeConverter. Non-numeric input is ignored (usually a transient typing state); numeric input is clamped to 6-72 pt. External changes toSelectedFontSize(reset-to-defaults, settings load) refresh the text viaPropertyChanged, while writes originating from the size box suppress the echo so typing isn't clobbered mid-keystroke. Also addsFontSizes(6-24), the same dropdown list the WPF host offered.ILSpy/Options/DisplaySettingsPanel.axaml- replaces the pixel-unitNumericUpDownwith a "Size" label (existingResources.Sizestring) plus an editableComboBox(IsEditable="True",Textbound to the points proxy, items 6-24), i.e. the WPF panel's shape on Avalonia 12. The previewTextBlockstill binds the raw pixel value, so it renders the true size.ILSpy.Tests/Options/DisplayFontSizeTests.cs- new tests (written red-first): default 13.33 px displays as "10", typed "12" stores 16 px, external pixel change raisesPropertyChangedand shows the right points, dialog-originated writes don't echo, garbage input is ignored, clamping at both ends, WPF-parity size list, and a headless UI test verifying the panel's size box is the editable ComboBox showing "10".DisplaySettings.SelectedFontSizeand its persistence are untouched, so settings files written by ILSpy 9.x still round-trip;EditorZoomand the live editor wire-up are unaffected.Full
ILSpy.Testssuite: 1178 passed, 0 failed, 4 skipped.🤖 Generated with Claude Code