According to the documentation , you can enable font smoothing inside CATextLayer:
Text can only be drawn using sub-pixel antialiasing when it is composited into an existing opaque background at the same time that it rasterized.
Here is how I understand this sentence:
@implementation CATextLayerWithFontSmoothing -(id)init { self=[super init]; if (self) { CALayer * whiteBackground = [CALayer layer]; CATextLayer * blackText = [CATextLayer layer]; [whiteBackground setBounds:NSMakeRect(0, 0, 300, 300)]; [blackText setBounds:NSMakeRect(0, 0, 300, 300)]; [whiteBackground setBackgroundColor:[NSColor whiteColor].CGColor]; [blackText setForegroundColor:[NSColor blackColor].CGColor]; [blackText setString:@"CATextLayer"]; [blackText setShouldRasterize:YES]; [self addSublayer:whiteBackground]; [self addSublayer: blackText]; } return self;
which does not work. Text is not drawn using sub-pixel smoothing.
objective-c core-animation antialiasing macos subpixel
alecail
source share