Re: Working with Paragraphs in Core Text
Re: Working with Paragraphs in Core Text
- Subject: Re: Working with Paragraphs in Core Text
- From: Iain Delaney <email@hidden>
- Date: Tue, 8 Jul 2008 19:13:27 -0400
I was having problems with both the creation of the style and the
application of it.
I think you example will work once I have the style defined, but I'm
still not clear on how you make the style.
The documentation is short of examples on this topic.
On 8-Jul-08, at 5:53 PM, Ricky Sharp wrote:
On Jul 8, 2008, at 3:23 PM, Iain Delaney wrote:
I'm trying to format some text using the new Leopard Core Text API.
Paragraphs, and the CTParagraphStyle object seem to have been
passed over in
the documentation, getting just a cursory mention.
Has anyone else managed to get paragraph styles to work? I'm
looking for a
simple example of how to create a paragraph style that centers a
paragraph,
and then some simple code for applying the paragraph style to the
attributed
string.
I've searched the documentation, the mailing lists and Google, and
I've
come up with nothing, so I'd really appreciate it if some could
help me out.
It's not clear what you're specifically having trouble with; the
creation of the style, or the application of it.
For the former, the docs do not appear to have any specific sample
code, but searching on 'CTParagraphStyle' in Xcode (API search) does
bring up few hits to include CTParagraphStyleCreate.
For the latter, once you have a CTParagraphStyleRef and your
attributed string, you should be able to use something like this:
CFStringRef string = CFSTR("some text");
CFMutableAttributedStringRef attrString =
CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
CFAttributedStringReplaceString (attrString, CFRangeMake(0, 0),
string);
CFAttributedStringSetAttribute(myAttrString, CFRangeMake(0,
someLength),
kCTParagraphStyleAttributeName, yourParagraphStyleRef);
This code snippet modeled from the one in 'Simple Paragraphs'
section of CoreText guide.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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