[Windows] Fix LineHeight values <1 having no effect by setting LineStackingStrategy to BlockLineHeight#31289
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.
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.
Also, could we include some Labels inside containers with constrained height?
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.
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 <5375137+PureWeen@users.noreply.github.com>
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 | |||



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