Re: Newbie: NSGlyph <-> unicode ?
Re: Newbie: NSGlyph <-> unicode ?
- Subject: Re: Newbie: NSGlyph <-> unicode ?
- From: "Anabelle Masour" <email@hidden>
- Date: Tue, 08 Jan 2002 23:49:28 +0000
Thanks you to Raphaele.Sebbe and AndyT. I got the information, that I
needed to use NSLayoutManager! I am sure now that NSFont does not have the
methods, which is strange.
I was able to write a method now to converst a NSString to NSGlyph data. I
still have a problem to convert from NSGlyph to unichar. But I think I can
avoid it.
Thank you very much. You were very helpful.
@implementation NSFont ( AMGlyph)
- (NSMutableData *) glyphsForString:(NSString *) string {
NSTextStorage *textStorage;
NSLayoutManager *layoutManager;
NSMutableData *glyphs;
NSDictionary *attributes;
unsigned int numberOfGlyphs;
attributes = [NSDictionary dictionaryWithObject:self
forKey:NSFontAttributeName];
textStorage = [[[NSTextStorage alloc] initWithString:string
attributes:attributes] autorelease];
layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];
[layoutManager release];
numberOfGlyphs = [layoutManager numberOfGlyphs];
glyphs = [NSMutableData dataWithLength:sizeof( NSGlyph) * numberOfGlyphs];
[layoutManager getGlyphs:(NSGlyph *) [glyphs mutableBytes]
range:NSMakeRange( 0, numberOfGlyphs)];
return( glyphs);
}
<Anabelle
.........
Rien ne sert de courir si on n'est pas pressi
et rien ne sert de marcher si on n'est pas foutu de tenir debout.
_________________________________________________________________
Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp.