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

coretext: PragmataPro with font-thicken=true looks wrong #2122

Closed
mitchellh opened this issue Aug 19, 2024 · 7 comments
Closed

coretext: PragmataPro with font-thicken=true looks wrong #2122

mitchellh opened this issue Aug 19, 2024 · 7 comments
Labels

Comments

@mitchellh
Copy link
Contributor

mitchellh commented Aug 19, 2024

Left is Ghostty, right is iTerm2

image

Maybe related:

It looks like the are two issues:

  1. Our glyphs are being cut off at the top (see the o which makes it really obvious I think)
  2. The thickness is blurry
@mitchellh
Copy link
Contributor Author

The freetype font backend looks fine. It doesn't support font-thicken anyways but I'm not noticing any rendering issues. This helps narrow it down to CoreText.

@mitchellh
Copy link
Contributor Author

Okay. Things I can confirm so far:

  • With font-thicken=false, Ghostty, iTerm2, TextEdit have identical rendering down to the individual pixel. I inspected each pixel of a letter and the colors fully match and pixel dimensions/locations fully match.
  • With font-thicken=true, things get messier and Ghostty looks different. Colors differ slightly and pixel locations differ slightly.

@mitchellh
Copy link
Contributor Author

#2123 fixes the clipping issue.

Now our pixel locations match perfectly, but our rendering is slightly darker. I'm not sure why yet.

@mitchellh
Copy link
Contributor Author

Okay, I've drawn directly to a CoreGraphics context and dumped the pixels and compared to what I'm pulling with DigitalColorMeter and the colors match exactly. So the question I have is: why is CoreGraphics giving us darker pixels than are showing up in TextEdit and iTerm2?

@mitchellh
Copy link
Contributor Author

It's darker because of gamma correction (or rather, a lack of it). Even though we set the colorspace of our drawable surfaces, we are not performing gamma correction yet on the RGB color values set manually by users or TUI programs (i.e. background, foreground, the full color palette, etc.). I jammed in some jank gamma correction multipliers into the OpenGL shader and was able to get very close values to macOS. I'm pretty sure this is the issue.

@mitchellh
Copy link
Contributor Author

Dedicated issue for gamma correction in #2125.

The remainder of this issue I believer is resolved. Our pixels are now in roughly identical positions between iTerm and TextEdit, our colors are just very slightly off (we skew darker which makes things look thicker).

Note I say "roughly identical": the dimensions are identical, but there are cases where we have a pixel here or a pixel there difference. When inspecting under something like DigitalColorMeter, I see the same thing with iTerm and TextEdit depending on font sizes too. Ultimately, I don't think these single pixel differences will make a noticeable difference, the major difference now is color.

@madig
Copy link

madig commented Dec 30, 2024

The freetype font backend looks fine. It doesn't support font-thicken anyways

It should, see https://freetype.org/freetype2/docs/reference/ft2-properties.html#no-stem-darkening. Granted, the quality is uneven across format drivers, but it exists :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants