Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: Font rendering inconsistencies depending on monitor DPI #4504

Open
mitchellh opened this issue Jan 3, 2025 · 13 comments
Open

macOS: Font rendering inconsistencies depending on monitor DPI #4504

mitchellh opened this issue Jan 3, 2025 · 13 comments
Labels
font Issue within the font stack (typically src/font) os/macos

Comments

@mitchellh
Copy link
Contributor

Discussion #4487
Discussion #3842

See the discussions for more details, screenshots. I'm not sure what is causing it yet and I don't have a firm reproduction but there are enough people reporting this with different fonts I feel confident it exists. There is some font rendering issue when it comes to using Ghostty on different monitor DPIs.

I tagged this as macOS since I've only since reports on macOS.

cc @qwerasd205

@mitchellh mitchellh added font Issue within the font stack (typically src/font) os/macos labels Jan 3, 2025
@qwerasd205
Copy link
Collaborator

I have a feeling this is caused by incorrect handling of dpi scaling. I'll look in to it some time in the coming week.

@charlesnicholson
Copy link

Another discussion with screenshots + video, if it's helpful:
#4197

@jmg-duarte
Copy link

jmg-duarte commented Jan 5, 2025

Adding to the discussion in #4487, the computer used in it is a 2022 MacBook Pro 13', in my 2021 MacBook Pro 14' the issue doesn't manifest at all when running version 8f5f432, build 8855.

This with the same monitors discussed in the thread.

@mohd-akram
Copy link

Running into this on a 27" 2560x1440 external monitor.

@mikelorant
Copy link

We should also consider tracking how the following value is set, as I feel it may be part of problem:

$ defaults -currentHost read -globalDomain AppleFontSmoothing
0

@charlesnicholson
Copy link

16" M2 MBP 2023 (macOS Sequoia 15.2) from #4197:

❯ defaults -currentHost read -globalDomain AppleFontSmoothing
2025-01-06 08:32:06.681 defaults[66549:5622257]
The domain/default pair of (kCFPreferencesAnyApplication, AppleFontSmoothing) does not exist

@eric-pigeon
Copy link

I was noticing lag when changing my DPI on external monitor as mirror display. Changed OSX setting to optimize for the external monitor and lag seems to be resolved.

@ctorgalson
Copy link

ctorgalson commented Jan 7, 2025

Just to add some information, I'm seeing something up with font rendering on Gnome desktop in external monitors as well.

As described above, fonts display perfectly on the laptop itself, but are distorted on the external monitor (at its native 2560x1440 resolution). This happens regardless of where the window is opened: in the laptop screen, Ghostty text looks great; in the external monitor it doesn't.

The screenshot shows, from top to bottom:

  • Ghostty
  • Black Box
  • Gnome Terminal

Image

Notice that while the Ghostty and Black Box are rendering the fonts at the same size, the fonts are much more similar in Black Box and Gnome Terminal. While there are some differences in kerning (as mentioned in e.g. #3482), the main differences are in the rendering of the letters themselves, which look as though they've been compressed vertically.

It's particularly visible in the 2, a, e, and o characters:

  • in '2', the diagonal stroke is much narrower than the rest of the letter, and the same stroke in the other samples,
  • in 'a', the space between the top two strokes is much narrower than in the other two specimens,
  • in 'e', the opening in the top of the letter is likewise very compressed when compared with the others,
  • in 'o', the letter is almost perfectly circular

Comparing the letters as a whole, the Ghostty type seems to have lost some height: the 't' is noticeably shorter from top to bottom, and all the all letters are visibly more square (compare e.g. the word 'NORMAL' in each terminal). It only seems to affect the letterforms (and numerals) though: the git symbol, also part of the font, isn't compressed like the letters.

@positron
Copy link

My terminal lives on my large 4k monitor running at native resolution.

I had to apply the following config to make the pixels line up exactly with how kitty renders text:

adjust-cell-width = "7%"

(Font is font-family = MesloLGS NF)

@wezm
Copy link

wezm commented Jan 14, 2025

I'm not sure this issue is macOS only. I'm on Linux and think I'm observing the same issue (that was also discussed in #3842). I have two 24" 4K screens running at 2x i.e. 4 pixels per-point like is common on macOS. The font I'm using is PragmataPro.

Image

In this screen shot each is set to a font size of 9.5 and the lines are aligned to the stem of the first 'r'. The lines are:

  • Ghostty
  • Tilda
  • Alacritty

Tilda is also GTK/freetype based. Note that even though Tilda uses a different rendering stack to Alacritty the advance of the glyphs matches up, whereas Ghostty drifts right quite quickly. Also note that the -- at the start of the line is not rendered clearly by Ghostty, but is by the other two.

Like this comment in the discussion I've been looking at PragmataPro for over a decade and the Ghostty rendering looked off, but I didn't quite know why until investigating a bit further.

@electron101
Copy link

electron101 commented Jan 14, 2025

Greetings!

The problem also exists on Linux.
On my 23 inch monitor (scale 100), the difference in fonts is noticeable. At 27 inches (with a scale of 150) there is no problem, or it is not noticeable to the naked eye.

On the left is Konsole, on the right is Ghostty.
Image

In Konsole the style is smooth, in Ghostty it is more jagged with a slight blur.

I really hope that this problem can be solved.

Update:
Kitty have same behaivor, but when I set 'text_composition_strategy legacy' this problem disappears, or at least is not noticeable to me.

@warpdesign
Copy link

Not sure this is related, but I also noticed that Ghostty seems to render fonts differently than iTerm for example. Here is the same font (same size) in iTerm vs Ghostty:

Image

iTerm's render (on the right) appears much sharper, and Ghostty renders the font like it was bold.

@pedronauck
Copy link

This is totally a block 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
font Issue within the font stack (typically src/font) os/macos
Projects
None yet
Development

No branches or pull requests