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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to