From 254aaf9645c364dc4b392e9ecab772dd12a8a7b2 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 19 Sep 2022 23:02:28 +0200 Subject: [PATCH 1/3] Fix font size rounding in the settings UI --- src/cascadia/TerminalSettingsEditor/Appearances.cpp | 10 ++++++++++ src/cascadia/TerminalSettingsEditor/Appearances.xaml | 1 + src/cascadia/TerminalSettingsEditor/pch.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.cpp b/src/cascadia/TerminalSettingsEditor/Appearances.cpp index e9760b88606..6d76cd1f2ca 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.cpp +++ b/src/cascadia/TerminalSettingsEditor/Appearances.cpp @@ -91,6 +91,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { InitializeComponent(); + { + using namespace winrt::Windows::Globalization::NumberFormatting; + // > .NET rounds to 12 significant digits when displaying doubles, so we will [...] + // ...obviously not do that, because this is an UI element for humans. This prevents + // issues when displaying 32-bit floats, because WinUI is unaware about their existence. + SignificantDigitsNumberRounder rounder; + rounder.SignificantDigits(6); + _fontSizeBox().NumberFormatter().as().NumberRounder(rounder); + } + INITIALIZE_BINDABLE_ENUM_SETTING(CursorShape, CursorStyle, winrt::Microsoft::Terminal::Core::CursorStyle, L"Profile_CursorShape", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING(AdjustIndistinguishableColors, AdjustIndistinguishableColors, winrt::Microsoft::Terminal::Core::AdjustTextMode, L"Profile_AdjustIndistinguishableColors", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(BackgroundImageStretchMode, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch, L"Profile_BackgroundImageStretchMode", L"Content"); diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 2b00dbe545c..55bfd3845b8 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -94,6 +94,7 @@ SettingOverrideSource="{x:Bind Appearance.FontSizeOverrideSource, Mode=OneWay}" Visibility="{x:Bind Appearance.IsDefault, Mode=OneWay}"> #include #include +#include #include #include #include From 8e1cae949e02d79289e23cb898da52ec81aba5ed Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 19 Sep 2022 23:16:39 +0200 Subject: [PATCH 2/3] Address feedback --- src/cascadia/TerminalSettingsEditor/Appearances.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.cpp b/src/cascadia/TerminalSettingsEditor/Appearances.cpp index 6d76cd1f2ca..49d3082350e 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.cpp +++ b/src/cascadia/TerminalSettingsEditor/Appearances.cpp @@ -98,6 +98,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // issues when displaying 32-bit floats, because WinUI is unaware about their existence. SignificantDigitsNumberRounder rounder; rounder.SignificantDigits(6); + // BODGY: Depends on WinUI internals. _fontSizeBox().NumberFormatter().as().NumberRounder(rounder); } From 4366d0ecd6f52cd64d3668c351366c55b7684745 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 19 Sep 2022 23:21:34 +0200 Subject: [PATCH 3/3] Reformat XAML --- src/cascadia/TerminalSettingsEditor/Appearances.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 55bfd3845b8..2e348581216 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -93,8 +93,8 @@ HasSettingValue="{x:Bind Appearance.HasFontSize, Mode=OneWay}" SettingOverrideSource="{x:Bind Appearance.FontSizeOverrideSource, Mode=OneWay}" Visibility="{x:Bind Appearance.IsDefault, Mode=OneWay}"> -