Re: Modifying glyph storage in NSLayoutManager
Re: Modifying glyph storage in NSLayoutManager
- Subject: Re: Modifying glyph storage in NSLayoutManager
- From: Douglas Davidson <email@hidden>
- Date: Mon, 17 Mar 2008 10:00:27 -0700
On Mar 17, 2008, at 9:31 AM, Ross Carter wrote:
What is the correct approach to take when you need NSLayoutManager
to make on-the-fly adjustments to the glyphs
Usually the glyph generator is used for default glyph generation, and
the typesetter is used to make adjustments to the glyphs that may
depend on layout--since it is the typesetter that is actually doing
the layout.
However, that's not your problem here, since it looks like you haven't
yet gotten to the generation of the dynamic text; you're just using a
static array of newGlyphs. The problem is that you need to inform the
layout manager of the character index <-> glyph index mapping. When
you use the bulk insertion method
insertGlyphs:length:forStartingGlyphAtIndex:characterIndex:, you get
the default behavior of a one-to-one character->glyph mapping for
those glyphs. If the mapping you want isn't one-to-one, that won't be
correct.
What you don't say is what the number of characters is that you want
to have mapped to these three glyphs. You're using the effective
range of an attribute, which is a somewhat dangerous practice--the
effective range in general is only guaranteed to be some range over
which the attribute applies, which may or may not be what you want.
What happens if you have two distinct occurrences of this attribute,
say two occurrences of your page number marker, that happen to lie
adjacent to each other?
A simple case would be if the range of characters you're mapping
happens to be of length 1. In that case, I believe you should just be
able to insert the glyphs one by one, specifying in each case the
correct glyph index and the same character index, and that should take
care of the mapping. If the character range is not 1, there are a
number of cases and it gets more complicated.
For some general information on the mapping, take a look at the AppKit
release notes for Leopard. I included some discussion there of the
constraints on the mapping between characters and glyphs. Probably we
should have more discussion in the documentation of exactly how one
goes about setting this mapping from within the glyph generator or
typesetter.
Douglas Davidson
_______________________________________________
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