Re: NSAttributedString drawing and NSText drawing
Re: NSAttributedString drawing and NSText drawing
- Subject: Re: NSAttributedString drawing and NSText drawing
- From: Joshua Scott Emmons <email@hidden>
- Date: Mon, 29 May 2006 12:53:55 -0500
When I draw the text with drawAtPoint: method of NSAttributedString
it's spacing is marginally different from when the equivalent RTF is
drawn by the NSText or NSTextView.
I just had this problem. It boils down to the fact that
NSTypesetter's behavior has been updated over the years as each new
version of OS X has been released. But, for compatibility's sake,
it's behavior can be changed to mimic older typesetting
implementations via
-[NSLayoutManager setTypesetterBehavior:(NSTypesetterBehavior)]
or
-[NSTypesetter setTypesetterBehavior:(NSTypesetterBehavior)]
The trick is, drawing convenience methods like -drawAtPoint: are set
to use NSTypesetterBehavior_10_2_WithCompatibility. If your
NSTextView's layout manager is set to use something else (I think
it's set to use NSTypesetterLatestBehavior by default[???] which on
Tiger resolves to NSTypesetterBehavior_10_4), then your line spacings
are subtly different.
The solution is to make sure both your text view and your -
drawAtPoint: are using the same behavior. Seeing as it's not possible
to change -drawAtPoint:, it's probably best to do a
[[myTextView layoutManager]
setTypeSetterBehavior:NSTypesetterBehavior_10_2_WithCompatibility];
That, or don't use -drawAtPoint:. If you if you already have a layout
manager with the text laid out in it (as you should in your
NSTextView), you ought to be able to draw directly from that (-
drawGlyphsForGlyphRange:atPoint:???). Then you won't have to worry
about different layouts, because the same layout manager is doing the
drawing in both cases.
Cheers,
-Joshua Emmons
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden