• 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: Rendering a fixed-width text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rendering a fixed-width text


  • Subject: Re: Rendering a fixed-width text
  • From: Scott Thompson <email@hidden>
  • Date: Wed, 01 Jul 2009 20:34:25 -0500


On Jun 30, 2009, at 9:52 AM, Riccardo Canalicchio wrote:

I'm developing an application for MacOSX, based on Core Animation.
I would like to know the best way to render a fixed-width text paragraph
inside a CALayer. I already tried with CATextLayer, which indeed gave me a
fixed-width text but I wasn't able to make height automatically adjust
accordingly to the number of lines in the paragraph.

To some extent it depends on your application.

I would recommend looking at the Cocoa text system and in particular how to assemble the text system "by hand":

http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/AssembleSysByHand.html

Using that you could determine the size and layout (line breaks) for a section of text (fixed-width or not). You could also use that system to draw the text onto the layer using the NSLayoutManager:

- (void)drawBackgroundForGlyphRange:(NSRange)glyphsToShow atPoint: (NSPoint)origin;
- (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint) origin;


If Cocoa is not to your liking, then you could also use the Core Text system, a C interface that the Cocoa Text (at least in part) is built upon:

http://gemma.apple.com/documentation/Carbon/Conceptual/CoreText_Programming/Introduction/Introduction.html

Scott

_______________________________________________

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


References: 
 >Rendering a fixed-width text (From: Riccardo Canalicchio <email@hidden>)

  • Prev by Date: Re: Programmatically adding to one big Finder selection ?
  • Next by Date: Re: Drawing the background of a single row in NSTableView
  • Previous by thread: Rendering a fixed-width text
  • Next by thread: Re: Rendering a fixed-width text
  • Index(es):
    • Date
    • Thread