# Implement perceptual gamma / contrast correction for Linux font rendering \(\#38862\) · gitcafe/zed

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

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

Visibility: public

Requested revision: e72021a26bf3e7e31d736eaaea89d6914149a9bf

Requested commit: e72021a26bf3e7e31d736eaaea89d6914149a9bf

Commit: e72021a26bf3e7e31d736eaaea89d6914149a9bf

Tree: 9f9f4b6a268f34cda5b5976d2890892228f6cfc7

Author: Kirill Bulatov

Committer: GitHub

## Message

```
Implement perceptual gamma / contrast correction for Linux font rendering (#38862)

Part of https://github.com/zed-industries/zed/issues/7992
Port of https://github.com/zed-industries/zed/pull/37167 to Linux

When using Blade rendering (Linux platforms and self-compiled builds
with the Blade renderer enabled), Zed reads `ZED_FONTS_GAMMA` and
`ZED_FONTS_GRAYSCALE_ENHANCED_CONTRAST` environment variables for the
values to use for font rendering.

`ZED_FONTS_GAMMA` corresponds to
[getgamma](https://learn.microsoft.com/en-us/windows/win32/api/dwrite/nf-dwrite-idwriterenderingparams-getgamma)
values.
Allowed range [1.0, 2.2], other values are clipped.
Default: 1.8

`ZED_FONTS_GRAYSCALE_ENHANCED_CONTRAST` corresponds to
[getgrayscaleenhancedcontrast](https://learn.microsoft.com/en-us/windows/win32/api/dwrite_1/nf-dwrite_1-idwriterenderingparams1-getgrayscaleenhancedcontrast)
values.
Allowed range: [0.0, ..), other values are clipped.
Default: 1.0

Screenshots (left is Nightly, right is the new code):

* Non-lodpi display

With the defaults:

<img width="2560" height="1600" alt="image"
src="https://github.com/user-attachments/assets/987168b4-3f5f-45a0-a740-9c0e49efbb9c"
/>


With `env ZED_FONTS_GRAYSCALE_ENHANCED_CONTRAST=7777`: 

<img width="2560" height="1600" alt="image"
src="https://github.com/user-attachments/assets/893bc2c7-9db4-4874-8ef6-3425d079db63"
/>


Lodpi, default settings:
<img width="3830" height="2160" alt="image"
src="https://github.com/user-attachments/assets/ec009e00-69b3-4c01-a18c-8286e2015e74"
/>

Lodpi, font size 7:
<img width="3830" height="2160" alt="image"
src="https://github.com/user-attachments/assets/f33e3df6-971b-4e18-b425-53d3404b19be"
/>


Release Notes:

- Implement perceptual gamma / contrast correction for Linux font
rendering

---------

Co-authored-by: localcc <work@localcc.cc>
```

## Parents

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

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