On Thu, Jan 6, 2011 at 10:28 AM, James Bucanek <subscri...@gloaming.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to