Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Vertical Text Alignment

Open robloo opened this issue 1 year ago • 30 comments

Describe the bug

I've seen this a few different places now with vertically aligned text. I'm just going to throw in some screen captures below.

What it looks like to me is text is vertically centered by calculating the height as (ascent - descent). However, this visually doesn't look quite right as the vast majority of text follows the baseline and doesn't go all the way to the descent. Therefore, I think vertical centering probably should be (ascent - baseline) for height.

Interestingly, TextBox looks correct to me. So this might unfortunately be a more general issue. TextBox is aware of how to calculate text vertical position using baseline instead of descent. However, other controls just use bounds and are not aware of more text-specific considerations... that opens up a can of worms if it's what is actually happening.

I have not noticed this before in WPF/UWP so I think they also calculate using the baseline in all controls; I could be wrong though and just wanted to point this out for those that know more than me in this area.

Expected behavior

Text should be vertically centered "visually" instead of "mathematically". Avalonia is currently accurate but doesn't quite look right to the eye.

Screenshots

DatePicker: image

ColorPicker > Components: image 12px above, 14/15px below

ComboBox image

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Version: 11.0-preview5+ at cbe0bb861a767b7bf7b268bbaa1d89dcf8523aea

Additional context Add any other context about the problem here.

robloo avatar Mar 14 '23 13:03 robloo