Re: Newbie and NSLayoutManager
Re: Newbie and NSLayoutManager
- Subject: Re: Newbie and NSLayoutManager
- From: Dave Keck <email@hidden>
- Date: Tue, 3 Feb 2004 19:10:17 -0500
I've never used NSLayoutManager before but this (or some slight
modification) should work:
where layoutManager is your NSLayoutManager...
----------------start code----------------
NSRange range = NSMakeRange(0, [layoutManager numberOfGlyphs]);
NSGlyph *glyphs = (NSGlyph *)calloc(range.length, sizeof(NSGlyph));
unsigned int glyphsCount = [layoutManager getGlyphs: glyphs range:
range];
int i;
NSLog(@"Total glyphs: %d", glyphsCount);
for (i = 0; i <= range.length - 1; i++)
{
NSLog(@"Glyph %d: %d", i, glyphs[i]);
}
NSLog(@"\n\n");
free(glyphs);
----------------end code----------------
First you allocate an array that can accommodate the number of
available glyphs, then you send getGlyphs: range: that array to fill it
up. To access the items in the array you use glyphs[i], where i is the
any number from 0 to (number of glyphs minus 1).
If this code doesn't make any sense I would recommend learning C really
well then coming back to Cocoa... it'll take time but it's well worth
it.
Enjoy,
Dave
Hello List,
I am a beginner, so please forgive this basic question. I want to use
NSLayoutManager's
- (unsigned)getGlyphs:(NSGlyph *)glyphArray range:(NSRange)glyphRange
to get the glyphArray. But what must I do to get it filled?
I tried:
NSGlyph glyphs= nil;
unsigned glyphsCount= [layoutManager getGlyphs:&glyphs range
glyphRange];
but this is not the way to do it.
As workaround I currently use NSLayoutManager's
- (NSGlyph)glyphAtIndex:(unsigned)glyphIndex
to get every glyph step by step, but that it not really satisfying.
_______________________________________________
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.