> 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 <graham....@bigpond.com> 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 (Cocoa-dev@lists.apple.com)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com
>
> This email sent to bravo...@gmail.com
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to