Cocoa text via Quartz CGLayer
Cocoa text via Quartz CGLayer
- Subject: Cocoa text via Quartz CGLayer
- From: Sander Stoks <email@hidden>
- Date: Fri, 5 Feb 2010 16:46:13 +0100
Hello all,
I noticed an interesting thing when using Cocoa Text via an intermediate Quartz CGLayer.
I want to draw rotated text, and I found out that the regular Cocoa Text drawing in that case looks surprisingly bad. I posted about this before, and got the suggestion of drawing to an offscreen bitmap instead, and rotating that. That works, but when I'm editing the text I see the text which is already there "jitter" on screen. I pruned this down to a minimal project which shows the problem. This can be downloaded at http://www.stoks.nl/TextTest.zip - it only contains a single NSView subclass which has selectable code paths (via an #if 0) for either drawing directly using NSLayoutManager's drawGlyphsForGlyphRange. This looks fine (as long as it's not rotated). The other path uses a CGLayer, sets the current NSGraphicsContext so it points to this layer, use drawGlyphsForGlyphRange again, and finally CGContextDrawLayerAtPoint to display the resulting text.
As you can see in http://www.stoks.nl/TextCompared.png, the text drawn via the intermediate CGLayer "shrinks" its intra-glyph-spacing as the string gets longer.
This has me stumped. Any pointers are most welcome!
Regards,
Sander_______________________________________________
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