NSAttributedString attribues misbehaving
-
I'm drawing some NSAttributedString's in a NSTextView with
[NSLayoutManager drawGlyphsForGlyphRange:atPoint:].
I set the text color by setting NSForegroundColorAttributeName in an
attributes dictionary and calling [NSTextView setTypingAttibutes:].
OK so far, works as expected. But then I also set
NSStrokeColorAttributeName
and NSStrokeWidthAttributeName to outline the text in a contrasting
color.
I get my outline... but the fill disappears.
Is there a reason for ignoring a requested attribute ?
.......Bob Clair -
On Tue, 23 Nov 2004 08:06:14 -0500, Robert Clair <rclair...> wrote:> I get my outline... but the fill disappears.Yeah ... I had the same problem a while ago. After playing around in
Text Edit with the font panel I've come to the conclusion that there
is no way to stroke and fill in one operation. I even tried setting
the background color hoping it would fill with that but no luck. I
think you're either stuck drawing your strings twice (once for fill,
once for stroke) or using the lower level stuff and rendering the
glyph paths directly.
Guy -
On Nov 23, 2004, at 5:06 AM, Robert Clair wrote:> I set the text color by setting NSForegroundColorAttributeName in an
> attributes dictionary and calling [NSTextView setTypingAttibutes:].
> OK so far, works as expected. But then I also set
> NSStrokeColorAttributeName
> and NSStrokeWidthAttributeName to outline the text in a contrasting
> color.
> I get my outline... but the fill disappears.
The value of NSStrokeWidthAttributeName controls this. It should be a
float-valued NSNumber, of which the absolute value controls the stroke
width, and the sign controls the drawing mode; a positive value causes
drawing using stroke alone, a negative value causes stroke and fill
drawing, and zero (or no value) causes fill only. If
NSForegroundColorAttributeName is present, it is used as the fill color
(if fill is drawn); if it is absent, the fill color is black (if fill
is drawn). If NSStrokeColorAttributeName is present, it is the color
used for the stroke (if stroke is drawn); if it is absent, the fill
color is also used for the stroke (if stroke is drawn). See
<AppKit/NSAttributedString.h>.
Douglas Davidson -
David -
Thanks for the quick reply. That did the trick.
Bob Clair


