# gpui_windows: Keep DirectWrite's default ligatures when no font features are set \(\#62338\) · gitcafe/zed

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

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

Visibility: public

Requested revision: ac6818fb2de7aaec9ee00d4ff697e948c8b8f0a3

Requested commit: ac6818fb2de7aaec9ee00d4ff697e948c8b8f0a3

Commit: ac6818fb2de7aaec9ee00d4ff697e948c8b8f0a3

Tree: 5c72969d82e2efebbbc689ae279492173ba09736

Author: Vlad Gaevsky

Committer: GitHub

## Message

```
gpui_windows: Keep DirectWrite's default ligatures when no font features are set (#62338)

On Windows, ligatures are off by default: they only show up if
`buffer_font_features` is set to something non-empty.

`generate_font_features` always creates an `IDWriteTypography` and
passes it to `apply_font_features` (`direct_write.rs:446-452`), and the
layout code calls `SetTypography` with it unconditionally (`:567`,
`:605`). `apply_font_features` returned early when no features were
configured, so an empty typography object reached DirectWrite.
`SetTypography` replaces the default feature set with exactly what the
typography contains, so `liga`, `clig` and `calt` ended up disabled.

Dropping the early return lets the rest of the function run, which adds
`liga`, `clig` and `calt` at 1. Users who configure features explicitly
are unaffected: that path already ran before this change, and an
explicit `liga: 0` still resolves to 0 through the same loop.

I went with this rather than guarding the two `SetTypography` calls,
because the function already owns the knowledge of which features
DirectWrite enables by default for the non-empty case, and guarding the
call sites would duplicate it in two places.

Other platforms are not affected: `generate_feature_array` on macOS
(`gpui_macos/src/open_type.rs:77`) appends one dictionary per configured
tag and does not replace the default feature set when the list is empty.

No test here: `apply_font_features` takes a live `IDWriteTypography`
from `CreateTypography()`, so covering it needs a real DirectWrite
factory and cannot run off Windows. I can extract the tag resolution
into a pure function and unit test that separately if you would prefer
it.

Checked on a Windows build with no `buffer_font_features` set: ligatures
render with this change and are absent without it.

Release Notes:

- Fixed ligatures being disabled on Windows unless
`buffer_font_features` was set
- [GPUI] N/A

Co-authored-by: Chris Biscardi <chris@christopherbiscardi.com>
```

## Parents

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

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