Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATextLayer subpixel antialiasing

My app draws layer-backed labels over a NSImageView.
The image view displays an image, and a tint color over that image.

This ensures that the contrast between the labels and the background image works.

enter image description here

As you can see, subpixel antialiasing is enabled and works correctly.

When you hover over those labels, they animate the frame property (Actually the view containing them).
While animating, the subpixel antialiasing is disabled, and when done enabled again.

enter image description here

This looks incredibly weird.

The layer is never redrawn, and the subpixel antialiasing doesn't have to change.
So I don't see a good reason why it shouldn't be displayed when animating.

I've tried everything I can think of.

  • Making the NSTextField opaque
  • Making the CATextLayer opaque
  • Giving the NSTextField a background-color
  • Giving the CATextLayer a background-color

Always the same result.

Disabling subpixel antialiasing for the labels is not an option, since it's not well readable on non-retina devices.


EDIT

I forgot that the layer is replaced with a presentationLayer while animating.
This layer probably does not support subpixel antialiasing, which is why it's disabled.

Now the question is if I can replace this presentationLayer with a CATextLayer.

What I also noticed is that setting shouldRasterize to YES enabled subpixel antialiasing also for animation, but only against the background color. So no background-color will bring no subpixel antialiasing.

like image 918
IluTov Avatar asked Apr 17 '26 02:04

IluTov


1 Answers

Is there any way that you can post a piece of sample code? I quickly mocked up an NSWindow, added an NSImageView, added a background-less NSTextField with setWantsLayer: set to YES. In my applicationDidFinishLaunching: I set a new rect on the NSTextField's Animator frame, but I didn't see any pixelation.

like image 113
blackirishman Avatar answered Apr 18 '26 17:04

blackirishman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!