Glyph from String
Glyph from String
- Subject: Glyph from String
- From: Craig Bakalian <email@hidden>
- Date: Thu, 19 Dec 2002 05:43:22 -0500
Hi,
Is there a way to return a glyph from a string? I am having
difficulty getting the following code to display a glyph in a NSView
subclass for characters in a music font that require "option-shift
.... " -
-(void)drawRect: (NSRect)rect
{
NSBezierPath *path = [NSBezierPath bezierPath];
NSRect viewFrame = [self bounds];
[[NSColor whiteColor]set];
[NSBezierPath fillRect: viewFrame];
[[NSColor blackColor]set];
NSGlyph sign = [musicFont _defaultGlyphForChar: theGlyph];
NSPoint p = NSMakePoint(viewFrame.size.width / 2.0,
viewFrame.size.height /2.0);
[path moveToPoint: p];
[path appendBezierPathWithGlyph: sign inFont: musicFont];
[path fill];
}
I can get the "option-shift... " characters of the music font to print
if I use code like this -
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
[attrs setObject: font forKey: NSFontAttributeName];
[string drawAtPoint:
NSMakePoint(20.0, 10.0) withAttributes: attrs];
Where the variable string is something as bizarre as @"Y", which
requires option ` shift u.
I need the precision of appendBezierPathWithGlyph because I am writing
a music notation app. drawAtPoint: withAttributes doesn't do the job
for me. So how does one get a glyph for @"Y"?
Craig Bakalian
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.