I'm trying to understand how to properly display text with condensed line spacing in a text field. When I set paragraph style properties lineHeightMultiple, maximumLineHeight, and minimumLineHeight I can achieve the effect of condensing the lines, but one side effect is that the top line of text just gets clipped off. So I thought that I'd just be able to move the text down with NSBaselineOffsetAttributeName (using a negative value), but that doesn't seem to have any effect. I'm using a line height here of 70% of the point size, but the clipping gets far worse the more condensed it gets.
1) Is there a better way to produce a condensed font line spacing?
2) Or how would you move the text rendering downward so it doesn't get clipped.
Thanks!
Here's the test project I'm working with https://www.dropbox.com/s/jyshqeuirujf71g/WhatThe.zip?dl=0
Screenshot: https://www.dropbox.com/s/h6sczflzsa57amr/ScreenShot.png?dl=0
self.label.maximumNumberOfLines = 0;
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
NSFont *font = [NSFont systemFontOfSize:80.0f];
CGFloat lineHeight = font.pointSize * .7f;
CGFloat natualLineHeight = font.ascender + ABS(font.descender) + font.leading;
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSTextAlignmentLeft;
paragraphStyle.lineHeightMultiple = lineHeight / natualLineHeight;
paragraphStyle.maximumLineHeight = lineHeight;
paragraphStyle.minimumLineHeight = lineHeight;
paragraphStyle.paragraphSpacing = 0.0f;
paragraphStyle.allowsDefaultTighteningForTruncation = paragraphStyle.lineBreakMode != NSLineBreakByWordWrapping && paragraphStyle.lineBreakMode != NSLineBreakByCharWrapping && paragraphStyle.lineBreakMode != NSLineBreakByClipping;
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
attributes[NSParagraphStyleAttributeName] = paragraphStyle;
attributes[NSKernAttributeName] = @(0.0f);
attributes[NSBaselineOffsetAttributeName] = @(-50.0f);
attributes[NSFontAttributeName] = font;
attributes[NSForegroundColorAttributeName] = [NSColor blackColor];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"Hello\nThere" attributes:attributes];
self.label.attributedStringValue = attributedString;