• 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
Re: Properly wrapping non-contiguous NSTextViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Properly wrapping non-contiguous NSTextViews


  • Subject: Re: Properly wrapping non-contiguous NSTextViews
  • From: Ross Carter <email@hidden>
  • Date: Wed, 17 Aug 2011 12:59:24 -0400

On Aug 16, 2011, at 3:40 PM, Nick Zitzmann wrote:

> Okay. As I just found out, TextEdit has the same problem as my application, and it turns out it is using almost the same code (I didn't write the original pagination code in the app). To see it for yourself:
>
> 1. Download this RTF - <http://dl.dropbox.com/u/13168713/Wrapping Problem.rtf>
> 2. Open it in TextEdit
> 3. Turn on wrap to page mode in the Format menu. At this point it looks like it wraps correctly, at least if your default page size is US Letter.
> 4. Open Page Setup
> 5. Change the margins by changing the paper size
>
> I changed it to a #10 envelope size, and you can see the text getting cut off at the bottom of the page views after the change.

OK, I see the problem. It looks like your source text was copied from a web page. (Fonts Arial and Verdana are a clue.) There is something peculiar in your text formatting. I'll bet that the web page embedded that text in a table and the conversion from web to RTF has left some table artifacts in the formatting. The NSParagraphStyle settings in your RTF document look like this:

NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 16/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n), DefaultTabInterval 36, Blocks (\n    \"<NSTextTableBlock: 0x14aa840>\"\n), Lists (null), BaseWritingDirection 0, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0";

Notice the NSTextTableBlock object. It should not be there.

Also, the minimum line height setting of 16 points is a relic of web layout that is not particularly useful in traditional text layout (IMHO), although is not a problem per se.

I ran the RTF doc through TextMate to remove all the formatting, pasted it in TextEdit, added back the formatting by hand, and the problem was gone. You could do this in code; just set NSParagraphStyle textBlocks to nil. Maybe while you're at it, set minimumLineHeight to 0 and, if you want more spacing, set lineHeightMultiple to 1.1 or thereabouts.

Hope this helps,

Ross
_______________________________________________

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

  • Follow-Ups:
    • [SOLVED] Re: Properly wrapping non-contiguous NSTextViews
      • From: Nick Zitzmann <email@hidden>
References: 
 >Properly wrapping non-contiguous NSTextViews (From: Nick Zitzmann <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Ross Carter <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Nick Zitzmann <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Martin Wierschin <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Nick Zitzmann <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Martin Wierschin <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Nick Zitzmann <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Ross Carter <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Nick Zitzmann <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Ross Carter <email@hidden>)
 >Re: Properly wrapping non-contiguous NSTextViews (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: +[UINib nibWithNibName:bundle:] and ~iPhone
  • Next by Date: Re: August Cocoaheads - Silicon Valley Meeting
  • Previous by thread: Re: Properly wrapping non-contiguous NSTextViews
  • Next by thread: [SOLVED] Re: Properly wrapping non-contiguous NSTextViews
  • Index(es):
    • Date
    • Thread