NSTextView, NSTextStorage, NSParagraph and lineHeight
NSTextView, NSTextStorage, NSParagraph and lineHeight
- Subject: NSTextView, NSTextStorage, NSParagraph and lineHeight
- From: Keith Renz <email@hidden>
- Date: Thu, 10 Oct 2002 18:32:36 -0400
I need to compact text in an NSTextView both horizontally (kerning) and
vertically (line spacing (leading) and/or line height). The following
code does what I want visually, but it really messes up the text
selection highlighting. I've played with all sorts of combinations of
line heights, line spacing, paragraph spacing, etc., but the
highlighting problem exists whenever the line height is set to
something smaller than the font's "natural" line height. Any ideas?
Thanks,
Keith
- (void)bidPackageChanged:(NSNotification *)notification
{
NSFont *font;
NSNumber *kerning;
NSMutableParagraphStyle *paragraph;
NSDictionary *attributes;
// Load the text view from the bid package's string.
[textView setString:[bidPackage linesString]];
// Set the text attributes.
font = [NSFont fontWithName:@"Courier" size:11];
kerning = [NSNumber numberWithFloat:-1.0];
// Pin the line height.
// NOTE: This has ill effects on selection highlighting.
paragraph = [[NSMutableParagraphStyle alloc] init];
[paragraph setMinimumLineHeight:11.0];
[paragraph setMaximumLineHeight:11.0];
attributes = [NSDictionary dictionaryWithObjectsAndKeys:font,
NSFontAttributeName, kerning, NSKernAttributeName,
paragraph, NSParagraphStyleAttributeName, nil];
[[textView textStorage] setAttributes:attributes range:NSMakeRange(0,
[[textView textStorage] length])];
[paragraph release];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.