Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Hi all
In order to create multiple paragraph(s) using CoreText do we need to set CTFrameSetter seperately for each paragraph? I am trying to apply settings for various paragraph like alignment, paragraph spacing etc but it does not apply. Though I am successfully able to apply font to them.
Code:
CGFloat ls = height;
		CTParagraphStyleSetting setting;
		setting.spec = kCTParagraphStyleSpecifierParagraphSpacing;
		setting.valueSize = sizeof(CGFloat);
		setting.value = &ls;
		CFIndex theNumberOfSettings = 1;		
		CTParagraphStyleSetting settings[1] = {
			//{kCTParagraphStyleSpecifierAlignment, sizeof(alignment), &alignment},
			{kCTParagraphStyleSpecifierParagraphSpacing, sizeof(CGFloat), &ls},			
		};
		//CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, sizeof(settings) / sizeof(settings[0]));
		CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, theNumberOfSettings);
		
		CFStringRef keys[] = { kCTParagraphStyleAttributeName };
		CFTypeRef values[] = { paragraphStyle };
		CFDictionaryRef paraAttribute = CFDictionaryCreate(
												  NULL, 
												  (const void **)&keys, 
												  (const void **)&values,
												  sizeof(keys) / sizeof(keys[0]), 
												  &kCFTypeDictionaryKeyCallBacks, 
												  &kCFTypeDictionaryValueCallBacks
												  );
		[htmlContent addAttributes:(NSDictionary*) paraAttribute range: applyToRange];
		//CFRelease(paragraphStyle);
		//CFRelease(attr);

here htmlContent is the NSMutableAttributedString. What is wrong with this code? Any idea?
Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.