-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fix LineHeight values <1 having no effect by setting LineStackingStrategy to BlockLineHeight
#31289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rmarinho
merged 10 commits into
dotnet:net10.0
from
MartyIX:feature/2025-08-22-windows-Change_the_LineStackingStrategy_to_BlockLineHeight_for_Labels
Sep 19, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
341c958
Test
Copilot 5c23d87
Actual change
MartyIX 0e013b7
Revert approach number 1
MartyIX 5036b7c
Approach number 2
MartyIX 90199fb
Disable test on Android
MartyIX eada6e3
Add snapshots for Windows, iOS and mac
MartyIX e42304a
Add snapshots for broken tests
MartyIX 7a5ae80
Improve test
MartyIX 5c97da7
Improve test
MartyIX b11cd35
Update snapshots
MartyIX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
155 changes: 155 additions & 0 deletions
155
src/Controls/tests/TestCases.HostApp/Issues/Issue24520.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage | ||
| xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue24520"> | ||
|
|
||
| <VerticalStackLayout> | ||
| <Label Text="Labels without spans" FontAttributes="Bold" /> | ||
|
|
||
| <Grid> | ||
| <Grid.ColumnDefinitions> | ||
| <ColumnDefinition Width="Auto"/> | ||
| <ColumnDefinition Width="*"/> | ||
| </Grid.ColumnDefinitions> | ||
|
|
||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| </Grid.RowDefinitions> | ||
|
|
||
| <Label Grid.Row="0" Grid.Column="0" BackgroundColor="Gray" Text="1. No LineHeight Specified" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="0" Grid.Column="1" BackgroundColor="Green" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="2" Grid.Column="0" BackgroundColor="Gray" Text="2. LineHeight=0.8" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="2" Grid.Column="1" BackgroundColor="Red" LineHeight="0.8" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="4" Grid.Column="0" BackgroundColor="Gray" Text="3. LineHeight=0.2" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="4" Grid.Column="1" BackgroundColor="Green" LineHeight="0.2" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="6" Grid.Column="0" BackgroundColor="Gray" Text="4. LineHeight=0.4" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="6" Grid.Column="1" BackgroundColor="Red" LineHeight="0.4" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="8" Grid.Column="0" BackgroundColor="Gray" Text="5. LineHeight=1.0" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="8" Grid.Column="1" BackgroundColor="Green" LineHeight="1.0" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="10" Grid.Column="0" BackgroundColor="Gray" Text="6. LineHeight=1.2" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="10" Grid.Column="1" BackgroundColor="Red" LineHeight="1.2" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="12" Grid.Column="0" BackgroundColor="Gray" Text="7. LineHeight=1.4" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="12" Grid.Column="1" BackgroundColor="Green" LineHeight="1.4" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="14" Grid.Column="0" BackgroundColor="Gray" Text="8. LineHeight=1.6" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="14" Grid.Column="1" BackgroundColor="Red" LineHeight="1.6" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="16" Grid.Column="0" BackgroundColor="Gray" Text="9. LineHeight=2.0" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="16" Grid.Column="1" BackgroundColor="Green" LineHeight="2.0" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
|
|
||
| <Label Grid.Row="18" Grid.Column="0" BackgroundColor="Gray" Text="10. LineHeight=4.6" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="18" Grid.Column="1" BackgroundColor="Red" LineHeight="4.6" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
| </Grid> | ||
|
|
||
| <Label Text="Labels with span" FontAttributes="Bold" Margin="0,5,0,0" /> | ||
|
|
||
| <Grid> | ||
| <Grid.ColumnDefinitions> | ||
| <ColumnDefinition Width="Auto"/> | ||
| <ColumnDefinition Width="*"/> | ||
| </Grid.ColumnDefinitions> | ||
|
|
||
| <Grid.RowDefinitions> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="30"/> | ||
| <RowDefinition Height="5"/> | ||
| <RowDefinition Height="150"/> | ||
| </Grid.RowDefinitions> | ||
|
|
||
| <Label Grid.Row="0" Grid.Column="0" BackgroundColor="Gray" Text="1. No LineHeight Specified" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="0" Grid.Column="1" BackgroundColor="Green" LineHeight="0.8" FontSize="20"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Normal" FontFamily="Arial"/> | ||
| <Span Text="Special" FontFamily="OpenSansRegular"/> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Label Grid.Row="2" Grid.Column="0" BackgroundColor="Gray" Text="2. LineHeight=0.4" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="2" Grid.Column="1" BackgroundColor="Red" LineHeight="0.4" FontSize="20"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Normal" FontFamily="Arial"/> | ||
| <Span Text="Special" FontFamily="OpenSansRegular"/> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Label Grid.Row="4" Grid.Column="0" BackgroundColor="Gray" Text="3. LineHeight=1.2" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="4" Grid.Column="1" BackgroundColor="Green" LineHeight="1.2" FontSize="20"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Normal" FontFamily="Arial"/> | ||
| <Span Text="Special" FontFamily="OpenSansRegular"/> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Label Grid.Row="6" Grid.Column="0" BackgroundColor="Gray" Text="3. LineHeight=1.6" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="6" Grid.Column="1" BackgroundColor="Red" LineHeight="1.6" FontSize="20"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Normal" FontFamily="Arial"/> | ||
| <Span Text="Special" FontFamily="OpenSansRegular"/> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Label Grid.Row="8" Grid.Column="0" BackgroundColor="Gray" Text="3. LineHeight=2.0" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="8" Grid.Column="1" BackgroundColor="Green" LineHeight="2.0" FontSize="20"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span Text="Normal" FontFamily="Arial"/> | ||
| <Span Text="Special" FontFamily="OpenSansRegular"/> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
|
|
||
| <Label Grid.Row="10" Grid.Column="0" BackgroundColor="Gray" Text="3. LineHeight=2.0" FontSize="10" VerticalTextAlignment="Center" /> | ||
| <Label Grid.Row="10" Grid.Column="1" LineHeight="2" LineBreakMode="WordWrap" Background="Blue"> | ||
| <Label.FormattedText> | ||
| <FormattedString> | ||
| <Span>Lorem ipsum </Span> | ||
| <Span FontSize="30">dolor sit</Span> | ||
| <Span> amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. Iaculis massa nisl malesuada lacinia integer nunc </Span> | ||
| <Span FontSize="20">posuere</Span> | ||
| <Span>. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos.</Span> | ||
| </FormattedString> | ||
| </Label.FormattedText> | ||
| </Label> | ||
| </Grid> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
10 changes: 10 additions & 0 deletions
10
src/Controls/tests/TestCases.HostApp/Issues/Issue24520.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 24520, "Change the LineStackingStrategy to BlockLineHeight for Labels on Windows", PlatformAffected.UWP)] | ||
| public partial class Issue24520 : ContentPage | ||
| { | ||
| public Issue24520() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } |
Binary file added
BIN
+90.1 KB
src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/VerifyLineHeightRendering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue24520.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #if TEST_FAILS_ON_ANDROID // https://github.com/dotnet/maui/issues/24504 | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue24520 : _IssuesUITest | ||
| { | ||
| public Issue24520(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Change the LineStackingStrategy to BlockLineHeight for Labels on Windows"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Label)] | ||
| public void VerifyLineHeightRendering() | ||
| { | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif | ||
Binary file modified
BIN
+676 Bytes
(100%)
...stCases.WinUI.Tests/snapshots/windows/ReduceInvalidateMeasuresUpdatingLabel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+813 Bytes
(100%)
...ses.WinUI.Tests/snapshots/windows/VerifyLabelWithFormattedTextAndLineHeight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+790 Bytes
(100%)
...estCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextTypeAndLineHeight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+508 Bytes
(100%)
...s/TestCases.WinUI.Tests/snapshots/windows/VerifyLabelWithTextWhenLineHeight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.3 KB
...ols/tests/TestCases.WinUI.Tests/snapshots/windows/VerifyLineHeightRendering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+769 Bytes
(110%)
...s/TestCases.WinUI.Tests/snapshots/windows/WordWrapLineBreakModeNoExtraSpace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+146 KB
src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/VerifyLineHeightRendering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this comment: #24504 (comment)