Re: Cocoa text via Quartz CGLayer
Re: Cocoa text via Quartz CGLayer
- Subject: Re: Cocoa text via Quartz CGLayer
- From: David Duncan <email@hidden>
- Date: Fri, 5 Feb 2010 12:06:26 -0800
On Feb 5, 2010, at 7:46 AM, Sander Stoks wrote:
> 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.
Its hard to tell because your text is selected in your screen shot, but I would guess that this has to do with subpixel antialiasing. By default your text will be drawn without a background. When you draw directly into the NSView however, there is an established background, that of the window, and so the text can be blended into it with subpixel antialiasing. When you draw to the CGLayer however, there is no such background, so the text is drawn without.
This typically manifests as the text not appearing as if it has the right weight (appears thin or not bold enough), although it is harder to tell in your case due to the selection area. If you see colored highlights when you zoom in on the image in one but not the other, then it is the issue I'm describing.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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