• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSAttributedString fill with gradient
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSAttributedString fill with gradient
      • From: David Duncan <email@hidden>
    • Re: NSAttributedString fill with gradient
      • From: Graham Cox <email@hidden>
References: 
 >NSAttributedString fill with gradient (From: Chris Purcell <email@hidden>)
 >Re: NSAttributedString fill with gradient (From: Graham Cox <email@hidden>)

  • Prev by Date: NSOutlineView Bad Scrolling Behavior
  • Next by Date: Re: NSAttributedString fill with gradient
  • Previous by thread: Re: NSAttributedString fill with gradient
  • Next by thread: Re: NSAttributedString fill with gradient
  • Index(es):
    • Date
    • Thread