On 23 Sep 2012, at 17:33, Kyle Sluder <k...@ksluder.com> wrote:
> 
> Attributes are specified on a character, rather than glyph, basis. So if
> you need to draw your characters with a separate color, you should
> probably override
> -showCGGlyphs:positions:count:font:matrix:attributes:inContext: to push
> and pop the foreground color you want before calling super. Should be a
> really simple override, because the context is already set up for you.
> 
> 
It turns out that customising NSGlyphGenerator is not necessary as the subclass 
merely calls its delegate, which is the layout manager.
So an override on NSLayoutManager of  - 
insertGlyphs:length:forStartingGlyphAtIndex:characterIndex: is appropriate.
I cache my substitute glyphs and swap them in as required (a secondary layout 
manager generates the substitute glyphs).

However there are issues.

Colourisation in - 
showCGGlyphs:positions:count:font:matrix:attributes:inContext:
will necessitate colouring by glyph value. So if a period is used to highlight 
a space then all periods in the text get highlighted regardless. 

Secondly, swapping out the tab glyph for another seems to break the tab 
functionality in the NSTextView.

Also, new line and carriage return glyph substitution doesn't seem to work. The 
substitute glyph is not drawn.
Perhaps its omitted as part of the fragment processing.

I imagine that  the second issue is related to the type setter, though that's 
just a guess.

Regards

Jonathan Mitchell
Mugginsoft LLP



_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to