• 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: NSLayoutManager and whitespace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLayoutManager and whitespace


  • Subject: Re: NSLayoutManager and whitespace
  • From: Scott Thompson <email@hidden>
  • Date: Thu, 13 Apr 2006 10:31:24 -0500


On Apr 13, 2006, at 7:27 AM, Scott Thompson wrote:
On Apr 13, 2006, at 6:16 AM, Ondra Cada wrote:
On 13.4.2006, at 9:52, Scott Thompson wrote:

What I want to do is measure some text which will be drawn later. The problem I'm having is for lines of text with trailing whitespace. The simplest case would be a single word with a space after it i.e. "Preferences_" (the underscore character in this case represents a space)

When I measure this string with a text layout object, it returns a width of something like 67 (for a particular font etc...).

If I then come back and draw that string into a field that is 67 points wide, the string hyphenates and wraps.

In my experience, NSLayoutManager indeed ignores any number of trailing spaces, but it goes both ways: they neither are taken into account when you get the usedRectForTextContainer:, but they *also* are ignored when the text is actually laid out. Namely, therefore, there should be no wrapping/hyphenation caused by trailing spaces either.


(Which is kind of natural, for these are not two different actions, but rather just twice the very same one: Layout Manager lays out the text somehow; usedRectForTextContainer: just returns the rectangle into which the text has been placed. *If* it wrapped/ hyphenated, it would return an appropriate /higher/ usedRectForTextContainer.)

Do you perhaps use a *different* service when you are "drawing the string into 67 points"? That would explain the problem.

No, but what you are saying makes more sense than what my brain came up with in the wee hours of the morning. The measured size is passed back to some code that arranges the text with some other elements. Perhaps by the time I'm asked to draw, the "draw into" rect is different from the originally measured rect. Let me go back and check that carefully to determine if that might be the case.

Well, no such luck and the wrapping happens during the measurement step... long before the drawing occurs.


I layout the text on one long line and use that to find the longest word (In this case 67) I then use that as the text container size. I guess this value is too exact. I imagine that the paragraph style or some other aspect of the text string means that the exact width I've calculated is still too narrow.

Scott

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSLayoutManager and whitespace
      • From: Ondra Cada <email@hidden>
References: 
 >NSLayoutManager and whitespace (From: Scott Thompson <email@hidden>)
 >Re: NSLayoutManager and whitespace (From: Ondra Cada <email@hidden>)
 >Re: NSLayoutManager and whitespace (From: Scott Thompson <email@hidden>)

  • Prev by Date: User Defaults Bindings confusion
  • Next by Date: Help with NSOutlineView selection
  • Previous by thread: Re: NSLayoutManager and whitespace
  • Next by thread: Re: NSLayoutManager and whitespace
  • Index(es):
    • Date
    • Thread