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 Text Jumping Around Despite Fixed Width Font. #17796

Open
l0hn opened this issue Dec 17, 2024 · 3 comments
Open

TextBlock Text Jumping Around Despite Fixed Width Font. #17796

l0hn opened this issue Dec 17, 2024 · 3 comments

Comments

@l0hn
Copy link

l0hn commented Dec 17, 2024

Describe the bug

When using a fixed width font, the bounds of a TextBlock keep changing when the text changes, despite the text having the same amount of characters.

e.g. a clock with the text changing from "00:18:11" to "00:18:12":

image

This causes the text to jump left and right as the time changes.

To Reproduce

  1. Use a TextBlock and a fixed width font
  2. Change the text in the TextBlock to an equal length string with different characters.
  3. Observe the bounds changing.

Expected behavior

Text should be rendered in the same position and not jump around.

Avalonia version

11.0.11

OS

macOS

Additional context

No response

@l0hn l0hn added the bug label Dec 17, 2024
@l0hn l0hn closed this as completed Dec 17, 2024
@l0hn
Copy link
Author

l0hn commented Dec 17, 2024

Hmm, I tried a few other fixed width fonts and it does seem to be an issue with a lot of them.

  • PT Mono
  • Consolas
  • Coureier New

All have the same problem

@l0hn l0hn reopened this Dec 17, 2024
@stevemonaco
Copy link
Contributor

Try upgrading to newest or nightly Avalonia. Besides that, try using LetterSpacing so that the kerning is consistent as a workaround. eg. <TextBlock Text="Testing" LetterSpacing="1" />

@l0hn
Copy link
Author

l0hn commented Dec 19, 2024

Hi @stevemonaco. Can confirm setting LetterSpacing="1" resolves this.

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

No branches or pull requests

3 participants