Valid glyphs in NSLayoutManager
Valid glyphs in NSLayoutManager
- Subject: Valid glyphs in NSLayoutManager
- From: Brock Brandenberg <email@hidden>
- Date: Tue, 10 Sep 2002 10:20:22 -0500
I have an application where I'm walking the glyph range in an
NSLayoutManager and retrieving the bounding boxes for the glyphs, but I'm
seeing valid glyphs that really aren't valid. For example, when setting the
title "Breckenridge" in Zapfino font, NSLayoutManager returns a range of
{0,12} and each glyph is a valid index, but two of the glyphs have a value
of zero. Interestingly, these two glyphs actually have bounding boxes (in
the font specified by their attributes) and they're different from one
another, but they don't apply to any visible glyphs. As a result, I get a
true boolean union of all the glyph rects that has a shape that does not
match the glyphs in cases such as this.
Is it necessary to test both the validity of the glyph and the value of it
like shown below? Do fonts ever have a valid glyph at index 0? Should Cocoa
not be returning isValidIndex = NO when this occurs?
For reference, here's the basic method of walking the glyph range that does
not work properly.
glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
for( i = glyphRange.location; i < NSMaxRange(glyphRange); i++ )
{
charIndex = [layoutManager characterIndexForGlyphAtIndex:i];
charDict = [textStorage attributesAtIndex:charIndex effectiveRange:nil];
charFont = [charDict objectForKey:NSFontAttributeName];
glyph = [layoutManager glyphAtIndex:i isValidIndex:&isValid];
if( isValid )
{
// do stuff with charIndex and charFont
}
By changing the test to this, it appears to work properly, but I'm skeptical
of the additional test:
if( isValid && glyph != 0 )
{
// do stuff with charIndex and charFont
}
Thanks,
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
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.