Quote:
Originally Posted by OMH
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), ¶graphAlignment},
{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.