Re: How to get "colored" font smoothing in a CALayer
Re: How to get "colored" font smoothing in a CALayer
- Subject: Re: How to get "colored" font smoothing in a CALayer
- From: Kyle Sluder <email@hidden>
- Date: Thu, 6 Jan 2011 11:06:25 -0800
On Thu, Jan 6, 2011 at 10:28 AM, James Bucanek <email@hidden> wrote:
> Greetings,
>
> The is probably more of a Carbon question than a Cocoa question, but since
> the problem starts with CALayer, I'll start here first.
Welcome to the madness of CALayer. I suggest you take a very long,
hard look at whether you want to continue down this path. :) In
particular, please read my rant from last month:
http://lists.apple.com/archives/cocoa-dev/2010/Dec/msg00464.html
The summary is that Core Animation really isn't good for making
traditional UI elements. It's great for things like Front Row and
Cover Flow or as a simple scene graph API. But there's too much
impedance mismatch between AppKit and CALayer. UIKit fares better
because it was designed with CALayer in mind.
> Searching the forums I found a reference to "sub-pixel smoothing". The
> solution was to fix some properties of the CGBitmapContext being drawn into,
> but CALayer doesn't (as far as I can tell) give you any control over the
> CGContext used when drawing the content of the layer.
You need to override -displayLayer (or implement -displayLayer: in
your layer's delegate) to create its own bitmap context. This context
must be filled with opaque contents before drawing the text for
subpixel antialiasing to work. But also, and this is *completely*
undocumented, you must create the bitmap context with the
kCGImageAlphaPremultipliedFirst and kCGBitmapByteOrder32Host options.
Without these options, text will not draw with subpixel AA even if you
fill the backing store with an opaque color before drawing.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden