• 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: 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

  • Follow-Ups:
    • Re: NSAttributedString fill with gradient
      • From: BravoBug Software <email@hidden>
References: 
 >NSAttributedString fill with gradient (From: Chris Purcell <email@hidden>)

  • Prev by Date: Re: Can't trap uncaught exceptions on Snow Leopard
  • Next by Date: Re: launching application after reboot
  • Previous by thread: NSAttributedString fill with gradient
  • Next by thread: Re: NSAttributedString fill with gradient
  • Index(es):
    • Date
    • Thread