linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.24k stars 93 forks source link

Always disable font smoothing when creating a CoreGraphicsContext #470

Open lord opened 2 years ago

lord commented 2 years ago

This makes all text rendered match the rendering used by Sketch. There's also this blog post by Tonsky that discusses it.

To me this seems reasonable to just disable for all apps. But could also make changing this a custom option that people can opt-in to? (Although I'd maybe still argue for defaulting to false)

Here are some @2x screenshots taken in Pages (which uses font smoothing if it's turned on system-wide) and Sketch (which always turns it off). The font is Mallory MicroPlus Bold Artboard

I notice the effect a lot more when it's white text on a dark background. Not sure if that's actually a rendering difference or just an optical illusion

lord commented 2 years ago

This may explain some of #383, but I'm not certain

cmyr commented 2 years ago

It looks like this option has finally been removed in monterey? In the back of my head the only possible concern I'd have, here, is whether this makes for a worse experience for folks on non-retina external monitors, but maybe this doesn't concern us.

Did you run into this as a problem, somewhere?

lord commented 2 years ago

Non-retina external monitors are a good point! Not sure how this would affect those. I'd be happy to amend this PR to make this an optional function call instead?

I guess I ran into this since I noticed the rendering seemed wrong on one of my projects, and I couldn't figure out a way to call this function without making modifications to Piet. Would be happy to be wrong!

cmyr commented 2 years ago

@lord yea, I think it's fine to have platform-specific helpers. I'm not sure where exactly I would hang this method. If you're using CoreGraphicsContext directly it could go there, otherwise we might need an extension trait?