• 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
glyphWithName: in Tiger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

glyphWithName: in Tiger


  • Subject: glyphWithName: in Tiger
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Tue, 24 May 2005 08:24:00 +0200

In Panther I have:

NSFont *font = [ NSFont userFontOfSize: 0.0 ];
NSGlyph glyph  = [ font glyphWithName: @"N" ] ;
// it returns 49 and:
[ aBezierPath appendBezierPathWithGlyph: glyph inFont: font];
// does indeed display an "N"

In Tiger (10.4.1) glyph is NSNullGlyph and an empty rectangle gets displayed.

1. question: is the code wrong and only works by good luck on Panther?

I created some work-around:

NSTextStorage *textStorage = [[NSTextStorage alloc] initWithString:@"NESW"];
[ textStorage setFont: font ];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
NSTextContainer *textContainer = [[NSTextContainer alloc] init];
[layoutManager addTextContainer:textContainer];
[textContainer release];
[textStorage addLayoutManager:layoutManager];
[layoutManager release];
NSRange glyphRange = [layoutManager glyphRangeForTextContainer: textContainer];
// Panther (10.3.9) returns {0,0} - Tiger returns {0,4} - Bug or feature?
// Yes, layoutManager is non-nil and it says about itself:
1 containers, text backing has 4 characters
selected character range {82925632, 2425081624} affinty: upstream granularity: character
marked character range {3221211760, 2686189792}
Currently holding 4 glyphs with 0 glyph holes and 0 layout holes.
Glyph holes: ()
Layout holes: ()


glyphRange.length = 4;	// another work-around

unsigned int yy = [ layoutManager getGlyphs: glyphs range: glyphRange ];
// if called with an empty range, it returns 0 (ok) but also sets the first array element to NSNullGlyph.


[textStorage release];

This works - but looks like quite an overkill.
2. question: is there some better way to get a glyph?

Maybe the glyph-names have changed in Tiger (so that the N-glyph is no longer called "N" but maybe "ascii character N".
3. question: Is there an invers function to glyphWithName:, something like:
- (NSString *)nameForGlyph:(NSGlyph)glyph ?


Kind regards,

Gerriet.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Persistent Stores and Packages ...
  • Next by Date: Re: Should I add properties to ABPerson?
  • Previous by thread: Re: Newbie: Chaining CIFilters together?
  • Next by thread: No Audio In QTMovieView
  • Index(es):
    • Date
    • Thread