I'm using this code to stroke a NSBezierPath with a wide, dashed, black line.
(c
and strForBezier
are defined somewhere else)
NSGlyph glyph;
for(n = 0; n < len; n++) {
glyph = [font glyphWithName: [strForBezier substringWithRange:NSMakeRange(n, 1)]];
[path appendBezierPathWithGlyph: glyph inFont: font];
}
CGFloat pattern2[4]; pattern2[0]=5*c; pattern2[1]=2*c; pattern2[2]=2*c; pattern2[3]=2*c;
[path setLineDash:pattern2 count:4 phase:0];
[path setLineWidth:c];
[path stroke];
[[NSColor blueColor] set ];
[path fill];
How can I get the black NSBezierPath ? I'm making the assumption that a NSBezierPath is built and filled to stroke the initial curve.
You can create a path by dashing and stroking an existing path, but that requires to use
CGPathRef
instead ofNSBezierPath
.If you're not comfortable with
CGPathRef
, you may create aNSBezierPath
then convert it to aCGPathRef
using the method described in Apple documentation Building a CGPathRef From a NSBezierPath Object (the reverse is also possible).