Skip to content

Some fonts are not rendered with the correct baseline #19547

@appel1

Description

@appel1

Describe the bug

On Windows, compared to WPF and browsers like Edge and Chrome, some fonts are rendered with the wrong baseline. Some also gets the wrong bounds.

For example:

  • Bahnschrift
  • Baskerville Old Face
  • Bauhaus 93
  • Britannic
  • Cambria Math
  • Footlight MT

To Reproduce

Run the attached project, it draws the system fonts using Avalonia and WPF side by side using the same font size and with layout rounding turned off in Avalonia to get similar results as WPF. WPF pixel aligns each row so we'll never get a pixel perfect result, but it shouldn't diff more than one screen px and the bounding boxes should be equal.

The Avalonia control NoLayoutRoundingTextBlock is just a TextBlock but the always on layout rounding is ignored to get more similar bounding boxes to WPF.

I've tried to draw a line where the baseline is and in Avalonia the ascent and descent.

Image

Comparing bounds to results in browser, Edge in this case.

Image Image

AvaloniaWpfFontComparison.zip

Expected behavior

Avalonia should render text at the same baseline and with the same bounds as WPF and web browsers.

Avalonia version

11.3.4

OS

Windows

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions