Re: NSAttributedString fill with gradient
Re: NSAttributedString fill with gradient
- Subject: Re: NSAttributedString fill with gradient
- From: BravoBug Software <email@hidden>
- Date: Sat, 19 Dec 2009 18:21:17 -0800
> Why would you even expect that to work? NSGradient is not a colour. At present there is no supported attribute for gradients.
Oh? You might want to let the folks at Apple know that ;)
[[NSColor selectedMenuItemColor] set];
NSRectFill(someRect);
-matt
On Thu, Dec 17, 2009 at 3:50 PM, Graham Cox <email@hidden> wrote:
>
> 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
>
_______________________________________________
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