• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSLayoutManagers and NSTypesetters and NSGlyphGenerators, oh my!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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, "&lt;" 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 &lt; as <. You can also have an additional representation, either maintained constantly or created as needed, that uses your control characters and &lt;. 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.

  • Follow-Ups:
    • Re: NSLayoutManagers and NSTypesetters and NSGlyphGenerators, oh my!
      • From: Kaelin Colclasure <email@hidden>
  • Prev by Date: Re: New to cocoa/database
  • Next by Date: Where are the headers for AppKit under XCode/panther
  • Previous by thread: Re: Adding Images to nib files in IB?
  • Next by thread: Re: NSLayoutManagers and NSTypesetters and NSGlyphGenerators, oh my!
  • Index(es):
    • Date
    • Thread