Re: NSLayoutManagers and NSTypesetters and NSGlyphGenerators, oh my!
Re: NSLayoutManagers and NSTypesetters and NSGlyphGenerators, oh my!
- Subject: Re: NSLayoutManagers and NSTypesetters and NSGlyphGenerators, oh my!
- From: Douglas Davidson <email@hidden>
- Date: Mon, 5 Jan 2004 14:16:32 -0800
On Dec 31, 2003, at 9:08 PM, Kaelin Colclasure wrote:
1) I want to embed some special, hidden control characters into the
character stream contained in an NSTextStorage.
a) These characters I designate as special should normally not show up
as visible glyphs at all. Think tabs, but without any effect on the
position of the next character / glyph position.
b) I do want insertion point positioning in the NSTextView to allow
putting the insertion point between two of these invisible control
characters.
c) It would be nice if I could also have a toggle to "Show Invisibles"
-- but this is not essential.
It's going to be a bit of a trick for your users to position the
insertion point between these invisible zero-width glyphs, but you
should be able to do this if you really want.
2) I want to have certain escape sequences in the character stream
mapped into a single character glyph.
a) For example, "<" should map to the glyph for '<'. (You can see
where this would be useful.)
b) Again, the ability to toggle this off and invalidate / re-render
the NSTextView would be nice, but not essential.
One possibility for both (1) and (2) would be to have two
representations of your text. In your NSTextStorage, you can put a
representation suitable for display using the text system--for example,
your invisible control characters could be represented as something in
Unicode that is zero-width, and your < as <. You can also have an
additional representation, either maintained constantly or created as
needed, that uses your control characters and <. Maintaining the
correspondence between the two can be done in a variety of ways. There
do not necessarily need to be two separate copies; a custom
NSTextStorage, for example, could maintain one representation in memory
but also present the other as needed. The toggling business then is
mainly a matter of altering the representation presented to the text
system.
If you really need to have a single representation stored in an
NSTextStorage, it is possible to override glyph generation using
NSGlyphGenerator. You may also need to override font fixing in an
NSTextStorage subclass to make sure that font fixing uses the actual
characters you want to represent. If you need to represent multiple
characters by a single glyph, it is advisable to insert sufficient
padding in the form of NSNullGlyphs immediately after the real glyph to
keep a one-to-one correspondence between characters and glyphs.
However, I would recommend investigating the two-representation
approach first; glyph generation is a tricky business.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.