Can someone tell me what is wrong here?
This method is part of a class derived from NSView, and is called from
drawRect.
Everything else I am drawing works: lines, regular text, etc. But I
cannot get a glyph to show up after being appended to an
NSBezierPath!!
It draws a tiny line segment as a test, then draws a rectangle around
where the glyph would go. The rectangle comes out different sizes,
depending on the font size I select. But no glyph appears inside!!
thanks,
jonathon
- (void) drawYLabels
{
NSString *label = @"Y axis";
NSFont *f = [NSFont userFontOfSize: 64];
NSTextStorage *ts;
ts = [[NSTextStorage alloc] initWithString: label];
NSLayoutManager *lm = [[NSLayoutManager alloc] init];
[ts addLayoutManager: lm];
NSRange r;
r.location = 0;
r.length = [label length];
NSGlyph g[r.length];
unsigned l = [lm getGlyphs: g range: r];
[[NSColor greenColor] set];
// draw rectangle for first glyph
NSRect grect = [f boundingRectForGlyph: g[0]];
grect.origin.x = 100;
grect.origin.y = 100;
[[NSBezierPath bezierPathWithRect: grect] stroke];
// test line draw
NSBezierPath *bp = [NSBezierPath bezierPath];
[bp moveToPoint: NSMakePoint(80, 80)];
[bp lineToPoint: NSMakePoint(90, 90)];
[bp moveToPoint: NSMakePoint(100, 100)];
[bp appendBezierPathWithGlyphs: g count: l inFont: f];
[bp fill];
NSLog(@"path: %@\n", [bp description]);
NSLog(@"# chars: %d glyphs: %c\n", l, g[0]);
NSLog(@"font: %@\n", [f description]);
}