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

DWriteCore inconsistent/wrong/non-fractional line spacing #5022

Open
timeester3648 opened this issue Jan 12, 2025 · 1 comment
Open

DWriteCore inconsistent/wrong/non-fractional line spacing #5022

timeester3648 opened this issue Jan 12, 2025 · 1 comment

Comments

@timeester3648
Copy link

Describe the bug

The line spacing between new lines in a DWriteCore text layout are not consistent or fractional. On smaller font sizes this becomes a noticable issue. Since it is a bit harder to show due to the small sizes in the TextRendering sample, I use my own application. This is at a point size of 72, and then scaled down to fit on the screen. The lines here seem mostly even.

Image

However, if I use a point size of 3, you can start seeing the difference in line spacing:

Image

and even more extreme, point size 0.5:

Image

some new lines do not even give a different value compared to the previous line's baselineOriginY in IDWriteTextRenderer1::DrawGlyphRun.

This is most likely due to the fact that the difference in baselineOriginY do not properly scale with font size, as can be seen in the attached videos.

Steps to reproduce the bug

  1. create a text layout with multi-line text, I just used some from the main page of https://www.lipsum.com/.
  2. make the text layout have a maximum width, so it wraps the words, without needing explicit new-lines.
  3. set the font size at quite small, so the non-fractional baselineOriginY becomes an issue.
  4. set the font size even smaller to where multiple lines sometimes have the same baselineOriginY.

Expected behavior

The difference in baselineOriginY is more consitently scaled with the font size used. And never has the same value as the previous any of the previous lines.

Screenshots

Non-fractional baselineOriginY (I printed them all and they were always integers)

RenderDoc.2025.01.12.-.00.56.29.04.mp4

And some lines do not even get a different baselineOriginY:

RenderDoc.2025.01.12.-.00.56.49.05.mp4

NuGet package version

None

Packaging type

Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

@timeester3648 timeester3648 changed the title DWriteCore inconsistent/wrong line spacing DWriteCore inconsistent/wrong/non-fractional line spacing Jan 12, 2025
@timeester3648
Copy link
Author

I just found out that I did indeed have pixel snapping on, but it still seems wrong that it is possible for 2 lines to have the same baseline offset.

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

1 participant