Skip to content

Conversation

@MatinAniss
Copy link
Contributor

@MatinAniss MatinAniss commented Jun 18, 2025

Improves font rendering on Windows by using IDWriteGlyphRunAnalysis::CreateAlphaTexture instead of ID2D1DeviceContext4::DrawGlyphRun for non emoji glyphs. This should also slightly improve performance as a Direct2D bitmap and bitmap scaler is not used anymore for non emoji glyphs. This implementation now aligns with how non emoji glyphs are done in many other applications like the Windows 11 Terminal, and some others projects listed in this #9403 (comment).

Closes #14113

Before on the left and after on the right. The images may not give a accurate representation of what the text will look like as it is dependent on the resolution you view the images at.

before_and_after

The most noticeable changes can be seen on smaller text with darker backgrounds, the text is slightly sharper.

typography

While this is a improvement, subpixel antialiasing is still missing but that will require some much larger changes to GPUI and all the platform text systems.

Release Notes:

  • N/A
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jun 18, 2025
@zed-industries-bot
Copy link

zed-industries-bot commented Jun 18, 2025

Messages
📖

This PR includes links to the following GitHub Issues: #9403
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 91cdebf

@JunkuiZhang
Copy link
Contributor

JunkuiZhang commented Jun 18, 2025

I looked into a bunch of implementations when I implemented this, mainly Windows Terminal and fontkit, and ended up going with the current approach because it most closely matched the rendering behavior and quality on macOS.

Also, one of the issues with AlphaTexture is that it returns incorrect bounds. You can actually see it in your screenshot, the top and bottom of the letters like a and e are cut off by 2–3 pixels.

Hopefully next time we can have a quick discussion before jumping into PR, I think it’ll help us stay aligned and avoid back-and-forth.

@MatinAniss
Copy link
Contributor Author

MatinAniss commented Jun 18, 2025

The current implementation is too blurry, adding antialiasing to the whole glyph when downscaling does not look very good. The text system should closely follow the platform implementation to give users a similar experience. So I believe following how the Windows terminal does it is better rather than trying to make it look like macOS.

Also, one of the issues with AlphaTexture is that it returns incorrect bounds. You can actually see it in your screenshot, the top and bottom of the letters like a and e are cut off by 2–3 pixels.

I don't see this issue, it just seems like the interpolation done to the glyphs in the current implementation has made all the letters thicker than they should be.

@MatinAniss MatinAniss force-pushed the better-font-rendering branch from 1180ebf to 8f4f52c Compare June 18, 2025 10:31
@maxdeviant maxdeviant changed the title windows: Better font rendering windows: Improve font rendering Jun 18, 2025
@MatinAniss MatinAniss force-pushed the better-font-rendering branch from 8f4f52c to 91cdebf Compare June 23, 2025 00:51
@vipexv
Copy link
Contributor

vipexv commented Jun 25, 2025

I personally like the current look, it does look a little more like MacOS which i prefer since i personally think Windows font rendering is horrible.

@MatinAniss
Copy link
Contributor Author

@vipexv This change isn't about opinion, it's about platform conformity. I am curious if you have tried the PR with your settings to see the changes on your device, if you are on a higher DPI screen or use larger font sizes the difference should be minimal. Some screenshots of the difference you are viewing would be more helpful.

@vipexv
Copy link
Contributor

vipexv commented Jun 25, 2025

@vipexv This change isn't about opinion, it's about platform conformity. I am curious if you have tried the PR with your settings to see the changes on your device, if you are on a higher DPI screen or use larger font sizes the difference should be minimal. Some screenshots of the difference you are viewing would be more helpful.

I also feel like if this is something that is going to be merged, we should also have a settings option to keep the current look for people who prefer the "MacOS" style.

And i haven't personally tried this PR, i'm just going off the screenshot above.

@MatinAniss
Copy link
Contributor Author

And i haven't personally tried this PR, i'm just going off the screenshot above.

Going off the screenshot may not represent what It will look like on your device. I suggest you try this change and see if there is a difference with your own settings, if there is some difference some screenshots would be appreciated.

I also feel like if this is something that is going to be merged, we should also have a settings option to keep the current look for people who prefer the "MacOS" style.

As for having a option to adjust the rendering I am not sure how that would look like, some finer grained options would be needed rather than a single option for this specific type of rendering you prefer, there is a issue that tracks that #8503.

@vipexv
Copy link
Contributor

vipexv commented Jun 25, 2025

After testing it my opinion is still the same, to me this looks 100x worse simply due to the fact that it's too sharp, i get that everyone has preferences but i feel like this should not be merged until we have an settings option to modify this, as i prefer the current "MacOS" look.

Before/After

image

@qystishere
Copy link
Contributor

Personally, I prefer a sharper look for the text, so it would be great to have this as an option.

{9A2B19A2-3342-4120-9DE3-3E6C1CCC6886}

@vipexv vipexv mentioned this pull request Jul 28, 2025
3 tasks
@mikayla-maki
Copy link
Member

I believe this work has been superseded by work the windows team is taking on, thanks for the contribution though!

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

6 participants