• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Glyph from String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Glyph from String
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Getting row and column information from an NSTextView
  • Next by Date: Re: "First Run" installation of Application support stuff?
  • Previous by thread: Getting row and column information from an NSTextView
  • Next by thread: Re: Glyph from String
  • Index(es):
    • Date
    • Thread