Re: NSAttributedString fill with gradient
Re: NSAttributedString fill with gradient
- Subject: Re: NSAttributedString fill with gradient
- From: Graham Cox <email@hidden>
- Date: Fri, 18 Dec 2009 10:50:53 +1100
On 18/12/2009, at 4:31 AM, Chris Purcell wrote:
> I've tried setting the gradient as NSForegroundColorAttributeName in the attributes dictionary when creating the string but as I expected that didn't work. How would I go about filling the string with a gradient?
Why would you even expect that to work? NSGradient is not a colour. At present there is no supported attribute for gradients.
You could create this effect by converting the string to its glyphs as a path and fill the path. Alternatively you can create a subclass of NSLayoutManager and override the method:
- (void)showPackedGlyphs:(char *)glyphs length:(NSUInteger)glyphLenglyphRange:(NSRange)glyphRange atPoint:(NSPoint)point font:(NSFont *)font color:(NSColor*)color printingAdjustment:(NSSize)printingAdjustment
and render the glyphs using a gradient. Doing that implies you'll need to set up a text system programatically, which is a fairly advanced topic - see:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArchitecture/TextArchitecture.pdf
--Graham
_______________________________________________
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