Re: NSLayoutManager strangeness
Re: NSLayoutManager strangeness
- Subject: Re: NSLayoutManager strangeness
- From: Aki Inoue <email@hidden>
- Date: Tue, 9 Aug 2005 18:24:26 -0700
Thomas,
The current Cocoa Text System implementation adds NSNullGlyph
"paddings" for deleted glyphs after ligature substitution to keep
char/glyph index identity as much as possible (for performance and
API ease of use). That's why -numberOfGlyphs returns 7 in your
case. So, glyph ID at index 3 should be NSNullGlyph.
We build up the NSTextStorage, NSTextContainer, NSLayoutManager
instances manually as it is explained in the Apple documentation
("Assembling the Text System by Hand") with the exception that we
do not use an NSTextView, since the glyphs are only used to create
OpenGL textures.
It appears you're manually extracting glyphs from NSLayoutManager and
rendering them to GL surface.
I'd recommend rendering with -drawGlyphsForGlyphRange:atPoint: by
subclassing NSLayoutManager. In your implementation of -
showPackedGlyphs:length:glyphRange:atPoint:font:color:printingAdjustment
:, you can render into GL context with the passed glyphs, color, and
font. Note the glyph packing on Mac OS X is
NSNativeShortGlyphPacking and the length argument is byte length (we
officially deprecated non-short glyph packings in Tiger).
Aki
Hello,
we are currently using NSLayoutManager to retrieve and draw glyphs
manually. We set up a NSTextStorage instance containing the string
"Zapfino" using the font Zapfino. We expected the - (unsigned)
numberOfGlyphs selector to return 6, since the characters "pf"
should be presented as a ligature, i.e. a single glyph. However,
the selector returns 7.
If we process each glyph in the TextStorage object individually, by
looping from 0 to numberOfGlyphs and calling
characterRangeForGlyphRange:acutalGlyphRange: we get an
actualGlyphRange length of 2 for the "pf" ligature as expected.
This seems to be a contradiction.
for (int i=0; i< [layoutManager numberOfGlyphs]; ++i) {
NSRange actualGlyphRange;
NSRange characterRange = [nativeLayoutManager
characterRangeForGlyphRange:NSMakeRange(i,1)
actualGlyphRange:&actualGlyphRange];
// actual glyph range is two for i = 2
}
We build up the NSTextStorage, NSTextContainer, NSLayoutManager
instances manually as it is explained in the Apple documentation
("Assembling the Text System by Hand") with the exception that we
do not use an NSTextView, since the glyphs are only used to create
OpenGL textures.
Can anybody explain this strange behaviour?
Regards,
Thomas
_______________________________________________
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
_______________________________________________
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