Skip to content
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

TextBlock render position error in 11.2.0 #17396

Closed
Coloryr opened this issue Nov 1, 2024 · 11 comments · Fixed by #17402
Closed

TextBlock render position error in 11.2.0 #17396

Coloryr opened this issue Nov 1, 2024 · 11 comments · Fixed by #17402
Labels

Comments

@Coloryr
Copy link
Contributor

Coloryr commented Nov 1, 2024

Describe the bug

TextBox render text position deviate.
At 11.2.0
image
At 11.1.4
image

To Reproduce

  1. Add a textblock
  2. Add text
  3. Use 11.2.0

Expected behavior

Same with 11.1.4

Avalonia version

11.2.0

OS

Windows

Additional context

No response

@Coloryr Coloryr added the bug label Nov 1, 2024
@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 1, 2024

The TextBlock

<TextBlock
    HorizontalAlignment="Center"
    FontSize="13"
    Text="{Binding Name, FallbackValue=1234}"
    TextAlignment="Center"
    TextTrimming="{Binding Trim}"
    TextWrapping="{Binding Wrap}" />

When

 HorizontalAlignment="Center"

will render in error position, delete it or set Left is work.

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 1, 2024

HorizontalAlignment and TextAlignment cannot be set the same Center

@adel-bakhshi
Copy link

I have the same problem and my text is not displayed in the middle. This problem appeared from version 11.2.0-rc2

@timunie
Copy link
Contributor

timunie commented Nov 1, 2024

@ADdy2142 do you have a snippet to reproduce?

@Gillibald
Copy link
Contributor

This reproduces the issue:

  <Border 
    Width="200" 
    HorizontalAlignment="Center"
    VerticalAlignment="Center">
    <TextBlock
      Text="Hello World"
      Foreground="White"
      HorizontalAlignment="Center"
      TextAlignment="Center">
    </TextBlock>
  </Border>

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 1, 2024

This reproduces the issue:

  <Border 
    Width="200" 
    HorizontalAlignment="Center"
    VerticalAlignment="Center">
    <TextBlock
      Text="Hello World"
      Foreground="White"
      HorizontalAlignment="Center"
      TextAlignment="Center">
    </TextBlock>
  </Border>

yes, set Width and off TextWrapping

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 4, 2024

I found only set TextAlignment=Center some time will render in error position

<TextBlock
    FontSize="20"
    Foreground="{setting:Theme FontColor}"
    Text="{Binding Text}"
    TextAlignment="Center"
    TextWrapping="Wrap" />

image
When the string is too long, line warp can also cause rendering in the wrong position.

@timunie
Copy link
Contributor

timunie commented Nov 4, 2024

@Coloryr please test this PR
#17402 (comment)

Thanks 🙏

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 4, 2024

@Coloryr please test this PR #17402 (comment)

Thanks 🙏

image

<Project>
  <PropertyGroup>
    <AvaloniaVersion>11.3.999-cibuild0052951-alpha</AvaloniaVersion>
  </PropertyGroup>
</Project>

Oh, it not this build?
image

Warp text gone?

<TextBlock
    FontSize="20"
    Foreground="{setting:Theme FontColor}"
    Text="{Binding Text}"
    TextAlignment="Center"
    TextWrapping="Wrap" />

image

<TextBlock
    HorizontalAlignment="Center"
    FontSize="20"
    Foreground="{setting:Theme FontColor}"
    Text="{Binding Text}"
    TextAlignment="Center"
    TextWrapping="Wrap" />

image

@timunie
Copy link
Contributor

timunie commented Nov 4, 2024

Make sure you have the nuget feed set correctly.

/cc @Gillibald

@Coloryr
Copy link
Contributor Author

Coloryr commented Nov 4, 2024

Make sure you have the nuget feed set correctly.

/cc @Gillibald

No, it's a problem with my nuget config file. I can get the corresponding Nuget package(11.3.999-cibuild0052951-alpha) now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants