• 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
Paragraph spacing (broken NSParagraphStyle?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Paragraph spacing (broken NSParagraphStyle?)


  • Subject: Paragraph spacing (broken NSParagraphStyle?)
  • From: Ben Kennedy <email@hidden>
  • Date: Tue, 5 Feb 2002 21:23:08 -0500

Hi all,

I am drawing text, and wish to have some pixels of space between
paragraphs. It strikes me that telling an NSParagraphStyle to
setParagraphSpacing is the way to do it; however, I have had no luck with
this -- my efforts are proudly ignored. e.g.:

NSParagraphStyle *para = [[NSMutableParagraphStyle
defaultParagraphStyle] mutableCopy];
NSMutableDictionary *attribs = [NSMutableDictionary mutableDictionary];
NSString *s;
[para setParagraphSpacing: 8.0];
[attribs setObject:para forKey:NSParagraphStyleAttributeName];
s = @"this is a test.\nWe should have several paragraphs of text
within here.\nI am expecting roughly 8 points of space at every newline.";
[s drawInRect:NSMakeRect(100,300,200,500) withAttributes:attribs];

Instead of using NSString's drawInRect:withAttributes: I have also tried
using NSLayoutManager to draw the string; results are the same in either
case. That is, every other character/paragraph attribute renders as
expected but the paragraph spacing appears to be ignored; the \n renders
as a soft newline. Any other paragraph/attribute changes (alignment,
font, etc) work as expected.

The NSParagraphStyle and other related text handling/rendering/etc.
documentation do not address this issue (other than the
setParagraphSpacing: method description which *seems* self-explanatory).

I have searched the cocoa-dev and omnigroup list archives and have found
nothing on point.

Is this an OS X bug or am I missing something? If the former, can anyone
suggest a practical work-around? (I see myself breaking the string up
into pieces, and using a for-loop with NSTextLayout and subsequently
resized-and-moved rects...)

-ben

--
Ben Kennedy, chief musician
zygoat creative technical services
613-228-3392 | 1-866-466-4628
http://www.zygoat.ca
_______________________________________________
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.

  • Prev by Date: Re: MenuBar icon in Cocoa?
  • Next by Date: Re: Printable area
  • Previous by thread: Constructing an NSURL with specified parameters
  • Next by thread: Re: Printable area
  • Index(es):
    • Date
    • Thread