On Jun 5, 2009, at 5:12 PM, Douglas Davidson wrote:


As I understand it, what you want to do is not to affect layout at all, but simply to cause certain glyphs not to be displayed. In general this can be problematic, because without knowledge of the font involved one can't necessarily guarantee that a particular character will be represented by a single glyph or vice versa; if the diacritic you are interested in is only a part of a single precomposed glyph in the font, then suppressing it would be difficult. With that caveat, though, what you're asking should be possible.

There is a glyph-level attribute maintained by the layout manager via -setNotShownAttribute:forGlyphAtIndex:/ notShownAttributeForGlyphAtIndex:, that could in principle be used for something of this sort, but it is usually used exclusively by the typesetter and it might be difficult to coordinate independent use of it. What might be cleaner, if you can readily identify the glyphs you are interested in, would be to subclass NSLayoutManager and override one of the drawing methods, such as - drawGlyphsForGlyphRange:atPoint: or -showPackedGlyphs:..., and simply suppress drawing of certain glyphs.

Some issues: you would in general need to split up the range passed in and call the super method with the remaining ranges; you might need to decide what to do about decorations such as underlines or strikethroughs for the affected ranges; depending on what you were doing, you might produce odd user experiences when editing the glyphs involved. I've presented examples at past WWDCs of the use of overriding these methods to add extra decoration near or around the glyphs in question, and I would imagine they would be equally suitable to subtracting from the displayed glyphs.

Douglas Davidson


Hello,
I subclassed NSLayoutManager's -showPackedGlyphs:… as per Mr. Davidson's suggestion above and it worked marvelously, except however it turns out that a few of the markings I want to hide are part of precomposed glyphs (I guess that's what you call them). In other words, I have some places where two or three characters, one of which I want to hide, corresponds to a single glyph, as I was warned above. Too bad, works 95% of the time. I haven't really looked too much into the -setNotShownAttribute… suggestion, as the documentation seems to state that it should only be called by NSTypesetter, and I'd like to try simpler measures first, if possible. My question is, could I subclass NSGlyphGenerator and insert a NSNullGlyph when I encounter a mark I want to hide? Or is that going to freak out the type setter? Also. the documentation on - generateGlyphsForGlyphStorage is rather sparse. Why are the glyphIndex and characterIndex arguments passed as pointers? What should they be on return?

Many thanks,
  Philip White_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to