AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.99k stars 2.25k forks source link

`TextBlock.TextAlignment` broken after upgrading from `11.1.4` to `11.2.0` #17450

Open Tyrrrz opened 1 week ago

Tyrrrz commented 1 week ago

Describe the bug

The following element tree:

<StackPanel
    Margin="8,32,8,8"
    HorizontalAlignment="Center"
    IsVisible="{Binding !Downloads.Count}"
    Orientation="Vertical">
    <materialIcons:MaterialIcon
        Width="256"
        Height="256"
        HorizontalAlignment="Center"
        Foreground="{DynamicResource MaterialDividerBrush}"
        Kind="Youtube" />

    <TextBlock
        HorizontalAlignment="Center"
        FontSize="18"
        FontWeight="Light"
        LineSpacing="8"
        TextAlignment="Center"
        TextWrapping="Wrap">
        <Run Text="Copy-paste a" />
        <Run FontWeight="SemiBold" Text="URL" />
        <Run Text="or enter a" />
        <Run FontWeight="SemiBold" Text="search query" />
        <Run Text="to start downloading" />
        <LineBreak />
        <Run Text="Press" />
        <Run FontWeight="SemiBold" Text="Shift+Enter" />
        <Run Text="to add multiple items" />
    </TextBlock>
</StackPanel>

Is rendered differently between 11.1.4 and 11.2.0.

On 11.1.4 it's rendered correctly:

image

On 11.2.0 it's rendered incorrectly:

image

Removing the TextAlignment property seems to fix the visual issues, but then the text is obviously not aligned as desired:

image

None of the other properties seem to have an effect.

To Reproduce

The project where this happens is open source, so it's easy to reproduce by just checking out the right refs.

To reproduce, simply run the only Avalonia project in the solution. The issue should present itself immediately as soon as the window is opened.

Expected behavior

The text should be center-aligned, as it was before 11.2.0.

Avalonia version

11.2.0

OS

Windows

Additional context

No response

rabbitism commented 1 week ago

https://github.com/AvaloniaUI/Avalonia/pull/17402

Tyrrrz commented 1 week ago

17402

Thanks. Although in my case, removing HorizontalAligntment on the text block did not help. Is it because the parent element also has HorizontalAlignment?

Gillibald commented 1 week ago

Try this build 11.3.999-cibuild0053119-alpha to make sure the fix is working for you