If you capture the entire laid-out text string as a single Bezier path, then you can fill it with whatever you want -- gradient, image, burning fire QTMovie, more text, etc. I've done it and it works. Of course, all of that takes a significant amount of effort. In my case, I already had all the fill mechanisms, so all I had to do was get the Bezier Path.
The SpeedyCatagories file in the SpeedometerView example has most of what you need to get the Bezier. You have to modify it somewhat to get everything you need. On 12/17/09 8:29 PM, "[email protected]" <[email protected]> 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/TextArch > itecture/TextArchitecture.pdf > > --Graham > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
