• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextView, NSTextStorage, NSParagraph and lineHeight
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSTextView, NSTextStorage, NSParagraph and lineHeight
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: case-insensitive strings - It's already in NSString!
  • Next by Date: Re: is protected broken, or am I?
  • Previous by thread: Re: NSMutableArray and releases etc
  • Next by thread: Re: NSTextView, NSTextStorage, NSParagraph and lineHeight
  • Index(es):
    • Date
    • Thread