Skip to content

Vertical Text Alignment #10658

@robloo

Description

@robloo

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 cbe0bb8

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions