• 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
Custom text layout (fast & easy), how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom text layout (fast & easy), how?


  • Subject: Custom text layout (fast & easy), how?
  • From: Allan Odgaard <email@hidden>
  • Date: Tue, 6 Aug 2002 01:23:56 +0200

Hi there,

I'm looking for advice on custom text layout, bypassing NSLayoutManager and friends.

The problem with using Apples framework is that it's not particularly geared toward speed. I have some 1 MB documents that needs to be layout'ed, and using NSLayoutManager it takes at least 10 seconds.

My main problem is finding out how to convert a character to a glyph -- preferably CGGlyph (which is != NSGlyph), as I use CGContextShowGlyphs() to display my glyphs (as I found this faster than some of the alternatives I tried) -- OTOH I use NSFont for dimensions, and this one works with NSGlyph. For the most parts it seems I can convert these simply using a typecast, but i think it failed for some special symbols like the copyright symbol (but perhaps that was just something else)...

As a quick little hack I tried simply to fill an array with values 0-255, converted it to an NSData and then NSString from NSData with Latin1 encoding, then provided the string to an NSLayoutManager object (as text storage) and requested the glyph range for 0-255. Then I could simply convert my chars using the result as a map (and using NSFont to request glyph dimensions/advancement), this cut down the layout to less than a second.

Problem is that this is not very flexible, i.e. it only works (currently) with iso-8859-1 chars, and even then I'm not sure it works with all fonts...

I know that char/glyph mapping can be many to many, but hell, there must be some support for this, cause NSLayoutManager would seem to already encapsulate the functions I require...

Kind regards Allan
_______________________________________________
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.

  • Prev by Date: Re: Accessor methods and (auto)release: conclusion
  • Next by Date: Using NSSpellServer and NSSpellChecker
  • Previous by thread: Re: Replacing Font/Size of NSMutableAttributedString, but not styles
  • Next by thread: Using NSSpellServer and NSSpellChecker
  • Index(es):
    • Date
    • Thread