Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-13-2010, 07:20 AM   #1 (permalink)
OMH
Registered Member
 
Join Date: Nov 2009
Location: Norway
Posts: 18
OMH is on a distinguished road
Default How to set leading in CoreText?

You can get it with CTFontGetLeading(aCTFont), but how do you SET it?

Can anyone please explain?

Is there another way around this? Do you have to set the space between the lines manually, perhaps?
OMH is offline   Reply With Quote
Old 09-13-2010, 08:44 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 1
Elaz is on a distinguished road
Default

Quote:
Originally Posted by OMH View Post
You can get it with CTFontGetLeading(aCTFont), but how do you SET it?

Can anyone please explain?

Is there another way around this? Do you have to set the space between the lines manually, perhaps?
You want want to set the maximum height line of the lines and pass it in the paragraph style attribute of the NSAttributedString you use with CoreText:

Code:
CTTextAlignment paragraphAlignment = kCTLeftTextAlignment;
		
		CGFloat maxLineHeight = 13.0;
		
		CTParagraphStyleSetting setting[2] = {
			{kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &paragraphAlignment},
			{kCTParagraphStyleSpecifierMaximumLineHeight, sizeof(CGFloat), &maxLineHeight}
		};

				
		CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(setting, 2);
		
		NSAttributedString* attrString = [[[NSAttributedString alloc] initWithString:contents attributes:
										   [NSDictionary dictionaryWithObjectsAndKeys:(id)myriadProRegular, (NSString*)kCTFontAttributeName,
											paragraphStyle, (NSString*)kCTParagraphStyleAttributeName, nil]] autorelease];
		
		
		CFRelease(paragraphStyle);
And than continue with the CTFrameSetter.
Not included here is the font creation, frame setter creation etc, but if you know your way around coretext, that should help you.
Elaz is offline   Reply With Quote
Old 09-14-2010, 03:04 AM   #3 (permalink)
OMH
Registered Member
 
Join Date: Nov 2009
Location: Norway
Posts: 18
OMH is on a distinguished road
Default

I needed to adjust _minimum_ line height, but then it worked nicely.

"kCTParagraphStyleSpecifierMinimumLineHeight". I found it in CTParagraphStyle.h, if anyone else are interested in these.

Thank you very much, Elaz!
OMH is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 344
13 members and 331 guests
Absentia, cgokey, fiftysixty, givensur, heshiming, iGamesDev, linkmx, michaelhansen, mraalex, PixelInteractive, raihan.zbr, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0