Re: drawGlyphsForGlyphRange layout issue
Re: drawGlyphsForGlyphRange layout issue
- Subject: Re: drawGlyphsForGlyphRange layout issue
- From: Kyle Sluder <email@hidden>
- Date: Sun, 23 Sep 2012 09:33:42 -0700
On Sun, Sep 23, 2012, at 01:55 AM, email@hidden wrote:
> >
> > On 22 Sep 2012, at 01:33, Graham Cox <email@hidden> wrote:
>
>
> > You might investigate an alternative (and much easier) solution.
> >
> > NSLayoutManager adopts the NSGlyphStorage protocol. That protocol declares a method, -layoutOptions, and one of the flags it can return is NSShowInvisibleGlyphs. Simply returning that flag may be all you need to do.
> >
> > In fact I think this is set for you when you call -setShowsInvisibleCharacters:YES
> >
> > I guess the difference is that it's all or nothing, which might be not the desired result.
> Works just for space characters, not other whitespace characters.
> Plus there is no attribute control so it isn't possible to colourise the
> invisible character glyph as I currently do.
> >
> >
> >
> > Another approach is to override -showCGGlyphs:positions:count:font:matrix:attributes:inContext: which is the primitive drawing method. All of the positioning and context flippedness has been handled by this point, so you can usually just go ahead and draw the characters. Inserting some other glyph at this point for the tab should be straightforward.
> >
> Good idea.
> I will investigate this one.
> However Kyle's idea of modifying the glyph stream may be better.
> It means that there is no second guessing required when it comes to
> positioning the substituted glyph.
> However, I don't know as yet whether I will be able to specify the
> required font colour. We shall see.
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.
--Kyle Sluder
_______________________________________________
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