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

Some custom fonts in TextBox do not align with the center of the caret #15768

Open
kurobirds opened this issue May 20, 2024 · 7 comments
Open
Labels

Comments

@kurobirds
Copy link

kurobirds commented May 20, 2024

Describe the bug

I have added a custom font to the TextBox, but the caret position is lower than the text.
Not every font has this issue, but I am currently experiencing it with Consolas and UniversNextPro.
This could be a font issue, but Word and Notepad++ don't have this problem.

To Reproduce

<TextBox Text="Default TextBox: lyg" />
<TextBox FontFamily="Consolas" Text="Consolas TextBox: lyg" />
<TextBox FontFamily="{StaticResource UniversNextProFont}" Text="UniversNextPro TextBox: lyg" />
image

Expected behavior

A custom font can align the caret in the center like the default font, or it could display as it does in Word and Notepad++.

Word with Consolas font:
image

Notepad++ with Consolas font::
image

Avalonia version

11.0.10, 11.1.0-beta2

OS

Windows

Additional context

No response

@kurobirds kurobirds added the bug label May 20, 2024
@rabbitism
Copy link
Contributor

rabbitism commented May 20, 2024

It should be fixed in #15481 but seems not.

And btw your second textbox is not consolas. Consolas is monospace font right?

Also can you also include a letter like g or y so it demostrate the lower bound of glyphs?

@kurobirds
Copy link
Author

kurobirds commented May 20, 2024

It should be fixed in #15481 but seems not.

And btw your second textbox is not consolas. Consolas is monospace font right?

Also can you also include a letter like g or y so it demostrate the lower bound of glyphs?

The second TextBox uses the UniversNextPro font. The Consolas font will display like this:
image

P.S.: I updated the demonstration for more clarity.

@Gillibald
Copy link
Contributor

The caret and glyph positions are not aligned to the pixel grid

@robloo
Copy link
Contributor

robloo commented May 20, 2024

Duplicate of #10658 I believe

@timunie
Copy link
Contributor

timunie commented May 21, 2024

@robloo not entirely sure this is an 100 % duplicate, as is about caret position, not font position in general. But could coupled, yes.

@robloo
Copy link
Contributor

robloo commented May 21, 2024

@timunie Caret position should be calculated from the font dimensions. So I expect the underlying issue is the same.

@timunie
Copy link
Contributor

timunie commented May 21, 2024

@Gillibald should decide if we want to close this in favor of #10658

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

No branches or pull requests

5 participants