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: default to sRGB color space #376

Merged
merged 1 commit into from
Sep 1, 2023
Merged

macos: default to sRGB color space #376

merged 1 commit into from
Sep 1, 2023

Conversation

bakunowski
Copy link
Collaborator

Ghostty is currently using the native color space on MacOS. For some Apple devices that means DCI-P3.

When specifying a hex color, it gets mapped incorrectly, because the color space is about 25% wider. As an example:
#0000FF needs to be shown as "maximally blue in sRGB space". P3 is a much wider gamut, and the same hex code will result in a different color, since P3 can show "more blue".

A lot of useful information about this has been already written down in the following threads:

To illustrate (screenshots taken on a 2021 MacBook 14" using "Digital Color Meter"):

Ghostty before this PR in native P3 color space:
Screenshot 2023-09-01 at 17 21 52

Ghostty before this PR in sRGB color space:
Screenshot 2023-09-01 at 17 22 08

Ghostty after this PR in P3:
Screenshot 2023-09-01 at 17 27 49

Ghostty after this PR in sRGB:
Screenshot 2023-09-01 at 17 27 55

Here's a side by side with onehalfdark in neovim:
Screenshot 2023-09-01 at 18 20 27
Left is this PR, right is main

Color schemes are generally designed with sRGB in mind. onehalf for example specifies sRGB for iTerm2 and VSCode.

Behaviour of other terminals:

  • iTerm (beta) allows to specify the color space, but it doesn't work in TUI applications, since (I suspect) they would also need to handle color spaces. This leads to a situation where onehalf would render correctly in the terminal, but incorrectly in neovim running in the same terminal. There's also a global config option to choose which color space to use. The stable release uses sRGB.
  • Alacritty uses sRGB (post v0.12.0)
  • Kitty allows to configure if sRGB or P3 is used globally.

@mitchellh
Copy link
Contributor

Thank you for the background, it does look like at least Kitty and Alacritty set this same config for NSWindow. As I said in Discord, I'm far from a color space expert but there seems to be enough background on this that this makes sense. thank you!

@mitchellh mitchellh merged commit b67811d into main Sep 1, 2023
@mitchellh mitchellh deleted the macos-color-space branch September 1, 2023 22:06
@bakunowski
Copy link
Collaborator Author

Awesome! Thank you for pulling me into the beta. Been such a joyful experience 😄

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

Successfully merging this pull request may close these issues.

2 participants