diff --git a/src/SamplesApp/UITests.Shared/Assets/Fonts/BravuraText.ttf b/src/SamplesApp/UITests.Shared/Assets/Fonts/BravuraText.ttf new file mode 100644 index 000000000000..3a9b330a2453 Binary files /dev/null and b/src/SamplesApp/UITests.Shared/Assets/Fonts/BravuraText.ttf differ diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index 64187ccf22b5..3d23a2cf7327 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -9646,6 +9646,7 @@ + @@ -9841,4 +9842,4 @@ - \ No newline at end of file + diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs index 3031dcb8f7bd..6e13aa3d9e3b 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs @@ -19,6 +19,7 @@ using static Private.Infrastructure.TestServices; using System.Collections.Generic; using System.Drawing; +using SamplesApp.UITests; using Uno.Disposables; using Uno.Extensions; using Point = Windows.Foundation.Point; @@ -733,6 +734,44 @@ public async Task When_SolidColorBrush_With_Opacity() ImageAssert.HasColorInRectangle(bitmap, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), Colors.Red.WithOpacity(.5)); } + + [TestMethod] + [UnoWorkItem("https://github.com/unoplatform/uno/issues/6528")] + public async Task When_Font_padding() + { + TextBlock tb1, tb2; + var sp = new StackPanel + { + Children = + { + new Border + { + BorderThickness = new Thickness(1), + BorderBrush = new SolidColorBrush(Microsoft.UI.Colors.Green), + Child = tb1 = new TextBlock + { + Text = "Default Font" + } + }, + new Border + { + BorderThickness = new Thickness(1), + BorderBrush = new SolidColorBrush(Microsoft.UI.Colors.Red), + Child = tb2 = new TextBlock + { + FontFamily = new FontFamily("ms-appx:///Assets/Fonts/BravuraText.ttf"), + Text = "Bravura Font" + } + } + } + }; + + await UITestHelper.Load(sp); + + // The 2 fonts don't have the same exact ascents and descents, so they're not supposed to be equal, just mostly the same + Assert.AreEqual(tb1.ActualHeight, tb2.ActualHeight, 5); + } + [TestMethod] [RunsOnUIThread] public async Task When_TextWrapping_Changed() diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs index a25f8b786c71..536d65fdd2c1 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs @@ -1151,5 +1151,41 @@ private static async Task LoadZeroSizeTextBoxAsync(Style style) await WindowHelper.WaitForIdle(); // Needed to account for lifecycle differences on mobile return textBox; } + + [TestMethod] + [UnoWorkItem("https://github.com/unoplatform/uno/issues/6528")] + public async Task When_Font_padding() + { + TextBox tb1, tb2; + var sp = new StackPanel + { + Children = + { + new Border + { + BorderThickness = new Thickness(1), + BorderBrush = new SolidColorBrush(Microsoft.UI.Colors.Green), + Child = tb1 = new TextBox + { + Text = "Default Font" + } + }, + new Border + { + BorderThickness = new Thickness(1), + BorderBrush = new SolidColorBrush(Microsoft.UI.Colors.Red), + Child = tb2 = new TextBox + { + FontFamily = new FontFamily("ms-appx:///Assets/Fonts/BravuraText.ttf"), + Text = "Bravura Font" + } + } + } + }; + + await UITestHelper.Load(sp); + + Assert.AreEqual(tb1.ActualHeight, tb2.ActualHeight); + } } }