-
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
Conversation
4e88956 to
f716eec
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
a8be0ad to
be858ef
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
be858ef to
e5c9b52
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Tests seem to pass. |
|
@bhavanesh2001 Could you please review/take a look? |
|
How does this work with spans? Looking at the WPF docs: https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.textblock.linestackingstrategy?view=windowsdesktop-9.0 We do support line heights on the label AND the spans... Not sure how they play together, but this PR may be regardless of how it looks. I do think that a 0.5 light height should apply, even if it looks a bit silly since the user did explicitly set it. You may actually want weird things with weird fonts... <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<!-- This TextBlock has a LineStackingStrategy set to "MaxHeight". -->
<TextBlock LineStackingStrategy="MaxHeight" LineHeight="10" Width="500" TextWrapping="Wrap"
Background="Yellow">
Use the <Span FontSize="30">LineStackingStrategy</Span> property to determine how a line box is
created for each line. A value of <Span FontSize="20">MaxHeight</Span> specifies that the stack
height is the smallest value that contains all the inline elements on that line when those
elements are properly aligned. A value of <Span FontSize="20">BlockLineHeight</Span> specifies
that the stack height is determined by the block element LineHeight property value.
</TextBlock>
<!-- Here is the same TextBlock but the LineStackingStrategy is set to "BlockLineHeight". -->
<TextBlock LineStackingStrategy="BlockLineHeight" LineHeight="10" Width="500" TextWrapping="Wrap"
Background="Blue" Margin="0,40,0,0">
Use the <Span FontSize="30">LineStackingStrategy</Span> property to determine how a line box is
created for each line. A value of <Span FontSize="20">MaxHeight</Span> specifies that the stack
height is the smallest value that contains all the inline elements on that line when those
elements are properly aligned. A value of <Span FontSize="20">BlockLineHeight</Span> specifies
that the stack height is determined by the block element LineHeight property value.
</TextBlock>
</StackPanel>
</Page>
|
Honestly, I don't really know. I need to take a deeper look. |
| <Label BackgroundColor="Green" LineHeight="1.4" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
| <Label BackgroundColor="Red" LineHeight="1.6" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
| <Label BackgroundColor="Green" LineHeight="2.0" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> | ||
| <Label BackgroundColor="Red" LineHeight="4.6" FontSize="20" Text="ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ"/> |
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.
Could we update the test to cover more cases? For example, using Spans.
Also, what happens with mixed fonts?
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="Normal " FontFamily="Arial"/>
<Span Text="Special" FontFamily="CustomFont"/>
</FormattedString>
</Label.FormattedText>
</Label>
With BlockLineHeight, if fonts have different block heights, this could cause inconsistent line spacing within the same label.
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.
Also, could we include some Labels inside containers with constrained height?
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.
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.
e5c9b52 to
cd25072
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
PureWeen
left a comment
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.
src/Controls/tests/TestCases.HostApp/Issues/Issue24520.xaml(107,40): Error XC0009: No property, BindableProperty, or event found for "WordWrap", or mismatching type between value and property.
Should be fixed |
Co-authored-by: PureWeen <[email protected]>
Co-authored-by: PureWeen <[email protected]>
2d49129 to
5c97da7
Compare
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| @@ -0,0 +1,23 @@ | |||
| #if TEST_FAILS_ON_ANDROID // https://github.com/dotnet/maui/issues/24504 | |||
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)



Description of Change
This PR is cherry-picked #31219 with an added UI test to see the result.
The PR is structured to commits this way:
LineStackingStrategy=BlockLineHeightin code (I believe it adds performance overhead)LineStackingStrategyneedlessly.Comparison of screenshots on Windows
This is just for comparison reasons:
Issues Fixed
Fixes #24520