Re: drawGlyphsForGlyphRange layout issue
Re: drawGlyphsForGlyphRange layout issue
- Subject: Re: drawGlyphsForGlyphRange layout issue
- From: "email@hidden" <email@hidden>
- Date: Mon, 24 Sep 2012 12:49:41 +0100
On 23 Sep 2012, at 17:33, Kyle Sluder <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden