# windows: Fix ascent/descent calculations \(\#40103\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/f1db1f3a3c933d8b4d35d83f6bbc49fd46749519)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: f1db1f3a3c933d8b4d35d83f6bbc49fd46749519

Requested commit: f1db1f3a3c933d8b4d35d83f6bbc49fd46749519

Commit: f1db1f3a3c933d8b4d35d83f6bbc49fd46749519

Tree: 347f4e2c1a6f21637f32c241a35d78923caacd93

Author: Cole Miller

Committer: GitHub

## Message

```
windows: Fix ascent/descent calculations (#40103)

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>
```

## Parents

- [02bdba80a415770be720a72484eaae5a5cebfe71](https://git.cafe/gitcafe/zed/commit/02bdba80a415770be720a72484eaae5a5cebfe71?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/f1db1f3a3c933d8b4d35d83f6bbc49fd46749519?format=markdown)
