Re: CoreText & NSMutableParagraphStyle maximumLineHeight
Re: CoreText & NSMutableParagraphStyle maximumLineHeight
- Subject: Re: CoreText & NSMutableParagraphStyle maximumLineHeight
- From: Peter C <email@hidden>
- Date: Wed, 21 Aug 2013 10:00:32 +0800
Just tested NSParagraphStyle lineHeightMultiple, the line space expands only. It is similar to NSParagraphStyle lineSpacing, no negative value possible.
Below is the method what I intended to do,
// lspace - 0.0 neutral , negative value the line height contracts and positive value line height expands
- (NSMutableParagraphStyle *)adjustLineSpacing:(CGFloat)lspace
{
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
NSLayoutManager *lm;
NSFont *fontObj;
CGFloat defLineHeight;
CGFloat calc;
if (lspace > 0.0)
paragraphStyle.lineSpacing = lspace;
else if (lspace < 0.0) {
fontObj = [NSFont fontWithName:_fontNameStr size:_fontSize];
lm = [[NSLayoutManager alloc] init];
defLineHeight = [lm defaultLineHeightForFont:fontObj];
[lm release];
calc = (lspace + 1.0) + defLineHeight;
if (calc < 1.0)
calc = 1.0;
paragraphStyle.maximumLineHeight = calc;
}
return [paragraphStyle autorelease];
}
-- Peter Chan
_______________________________________________
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