drawing text onto an NSImage
drawing text onto an NSImage
- Subject: drawing text onto an NSImage
- From: Ben Zotto <email@hidden>
- Date: Fri, 1 Dec 2006 12:47:19 -0800
Hey all,
I have a custom view into which I'm drawing text using an
NSLayoutManager's drawGlyphsForGlyphRange method, similar to what the
Sketch sample does. The custom view is flipped, which is apparently required for
NSLayoutManager to do this work correctly. This works as expected.
I would like to pre-cache some of this drawn text in some cases by
drawing into an NSImage (using the 10.3 lockFocus/draw/unlockFocus
technique) before compositing it to the screen. The NSImage has been set to flipped, but the text still
comes out wrong on it, with each individual line being vertically
mirrored, something that (unless I'm not bright enough to get it) can't
be fixed by applying an NSAffineTransform. Calling [[NSGraphicsContext
currentContext] isFlipped] returns NO when drawing to the image, which
is implied by the documentation and I assume somewhere at the cause of the problem.
There are a couple different ways I can steer clear of the cached text
in my app, but I haven't found an archive post that quite addresses
this topic, so I'm wondering if anyone can shed light on whether
drawing using the LayoutManager directly onto the NSImage can work, or
if not, could explain what's going on under the covers that causes this
behavior.
Thanks
Ben
_________________________________________________________________
Use Messenger to talk to your IM friends, even those on Yahoo!
http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe_______________________________________________
Cocoa-dev mailing list (email@hidden)
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