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

font(coretext): add config to adjust strength of font-thicken. #4531

Merged
merged 1 commit into from
Jan 5, 2025

Conversation

qwerasd205
Copy link
Collaborator

This is achieved by rendering to an alpha-only context rather than a normal single-channel context, and adjusting the brightness at which CoreText thinks it's drawing the glyph, which affects how it applies font smoothing (which is what font-thicken enables).

This is achieved by rendering to an alpha-only context rather than a
normal single-channel context, and adjusting the brightness at which
coretext thinks it's drawing the glyph, which affects how it applies
font smoothing (which is what `font-thicken` enables).
@qwerasd205
Copy link
Collaborator Author

qwerasd205 commented Jan 3, 2025

Screenshots

font-thicken = false

no-thicken

font-thicken = true

font-thicken-strength = 0

thicken-0

font-thicken-strength = 127

thicken-127

font-thicken-strength = 255

thicken-255

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question/comment. I'm happy to do that work myself later.

/// just the *lightest* thickening available.
///
/// CoreText only.
thicken_strength: u8 = 255,
Copy link
Contributor

@mitchellh mitchellh Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only thought here is should we use a f32 here instead of a u8. It feels like this would be more user-friendly to configure for a range of "min" to "max". And it also looks like the Apple API is a CGFloat anyways.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered it but it felt like false precision to me-- I'm not particularly bothered about it either way though so I'm fine with changing it to a float if you want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the argument, but the argument types match and the difference between subtle changes should not be noticeable enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it back, this causes hashing issues and I don't want to deal with it lol.

@mitchellh mitchellh merged commit 62dd468 into ghostty-org:main Jan 5, 2025
24 checks passed
@github-actions github-actions bot added this to the 1.0.2 milestone Jan 5, 2025
@qwerasd205 qwerasd205 deleted the adjustable-font-thicken branch January 5, 2025 22:33
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