Re: Drawing Text in an NSImage
Re: Drawing Text in an NSImage
- Subject: Re: Drawing Text in an NSImage
- From: Seth Willits <email@hidden>
- Date: Sat, 29 Aug 2009 14:21:34 -0700
On Aug 27, 2009, at 9:37 PM, Henry McGilton (Boulevardier) wrote:
drawAtPoint/drawInRect in NSString/NSAttributedString says...
"You should only invoke this method when an NSView object has focus."
"Don’t invoke this method while no NSView is focused."
When an image is focused, and you draw text, it'll definitely do
wonky things if the currently focused view is flipped. If we can't
use these methods, are we really supposed to drop down to
NSLayoutManager etc etc to draw a simple string? Is there really no
secret API for image-friendly string drawing? Just want to double
check before I have to go invent one...
Not quite sure what is the problem you're having here, Seth.
Create your NSImage. lockFocus on the image. Draw into the
image.
i have two apps that draw into images using drawAtPoint, and I don't
see
any problems relating to views . . .
String drawing always happens relative to the view's orientation, not
the image's. If the view is flipped and you draw into an image, then
draw that image, the string will be upside down. That's the reason I'm
assuming they say not to do it.
On Aug 27, 2009, at 11:30 PM, Uli Kusterer wrote:
I think, for the discussion of this particular API, an NSView object
having focus includes the case of an NSImage object having focus.
You may want to file a documentation bug requesting clarification.
Except experimentation says otherwise. The only way to get it to work
is to apply an NSAffineTransform manually to trick the string into
drawing the correct way (when the view is flipped).
If you know you have to do that it's not so bad, but it's a pain in
the butt trying to figure out that you need to do it.
--
Seth Willits
_______________________________________________
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