Skip to content

windows: Fix ascent/descent calculations#40103

Merged
cole-miller merged 1 commit intomainfrom
fix-wobble-windows
Oct 13, 2025
Merged

windows: Fix ascent/descent calculations#40103
cole-miller merged 1 commit intomainfrom
fix-wobble-windows

Conversation

@cole-miller
Copy link
Member

@cole-miller cole-miller commented Oct 13, 2025

This applies the same fix as #39886 for Windows.

Previously we were using GetLineMetrics to determine the ascent and descent values for each line. It seems like this has the same behavior as GetTypographicBounds on macOS, which is to return the minimum ascent and descent for the current state of the TextLayout object. This causes the ascent/descent to be unstable when adding or removing an emoji because a font fallback is triggered when an emoji is present on the line.

The issue is fixed by switching to font.GetMetrics to get the ascent and descent, which should always return stable values for the main font, instead of changing when there's a fallback. This also should support situations where we have multiple explicit fonts on the same line, although that probably can't be triggered in Zed right now.

Release Notes:

  • windows: Fixed a vertical shift in text layout when inserting or removing an emoji.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 13, 2025
@cole-miller cole-miller merged commit f1db1f3 into main Oct 13, 2025
25 checks passed
@cole-miller cole-miller deleted the fix-wobble-windows branch October 13, 2025 13:49
cole-miller added a commit that referenced this pull request Oct 14, 2025
cole-miller added a commit that referenced this pull request Oct 14, 2025
…40175)

This reverts commit f1db1f3.

This seems to have affected the vertical positioning of text that
doesn't contain emojis in a way that was unintended.

Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant