Scaling CALayer produces blurry/distorted text
Scaling CALayer produces blurry/distorted text
- Subject: Scaling CALayer produces blurry/distorted text
- From: Ajay Sabhaney <email@hidden>
- Date: Thu, 30 Jun 2011 03:28:55 -0600
Hello,
I have an application in which the user can continuously zoom and pan a canvas (kind of like Google Maps). On the canvas, a user can have multiple text items. Each text item is a Core Animation layer, and the text is drawn using NSLayoutManager's drawGlyphsForGlyphRange method.
When the canvas is zoomed in or out, the text item is scaled using CGContextScaleCTM. The text however, is blurry at certain zoom levels. If I set the magnification filter of the CALayer to kCAFilterNearest, it almost works, but at a few (seemingly random) zoom levels, there appear to be some artifacts.
Here are four links, each one showing different scenarios:
1) Using kCAFilterNearest magnification filter, at a zoom level where no artifacts are produced.
http://mothercreative.com/ajay/text/perfect.png
2) Using kCAFilterNearest magnification filter, at a zoom level where some artifacts are produced (areas in red).
http://mothercreative.com/ajay/text/artifacts1.jpg
http://mothercreative.com/ajay/text/artifacts2.png
3) Using the default magnification filter, notice blurriness.
http://mothercreative.com/ajay/text/blurry.png
I've ensured already that the frame rect is integral (so that the layer isn't sitting on half pixels), font smoothing is off, and antialiasing is on.
Any suggestions as to why these artifacts are showing up, or how to produce more clear results without using the kCAFilterNearest magnification filter, would be much appreciated.
Thanks,
Ajay
_______________________________________________
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