• 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: Part of an NSAttributedString that fit a rectangle ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Part of an NSAttributedString that fit a rectangle ?


  • Subject: Re: Part of an NSAttributedString that fit a rectangle ?
  • From: Eric Morand <email@hidden>
  • Date: Sun, 7 Aug 2005 18:17:23 +0200

Thanks Ricky !

It seems a bit complex for just a control but I've been able to isolate the glyphs that are drawn on each line, helping myself with the example you gave me.


Now, I have to draw these glyphs on screen and I can't use NSLayoutManager drawGlyphsForGlyphRange:atPoint: method because for some reason, it doesn't draw the glyphs where I ask it to : it draws them higher than the origin I pass to it, and I don't want to spend two weeks to understand why just for a button with warping title. And the NSAttributedString drawInRect method work like a charm.




Is there a way to create an attributed string with an array of glyphs ?



Le 7 août 05 à 16:39, Ricky Sharp a écrit :


On Aug 7, 2005, at 9:13 AM, Eric Morand wrote:


Is there a way to know what part of an attributed string fit in a rectangle, taking the line breaking mode into account ?


For example, let's say I have an attributed string whose string is "Hello COCOA-DEV List !" and whose line breaking mode is NSLineBreakByWordWrapping. And let's say that I have a rectangle that is too narrow to fit the entire string and that will only be able to contain "Hello COCOA-DEV" when the attributed string is drawn inside. How can I know programatically that the word "List" has been truncated ?



Take a look at:

<http://developer.apple.com/samplecode/TipWrapper/TipWrapper.html>

Specifically look at the NSTextView_Lines.h/.m. It provides a category on NSTextView where you can obtain a line count. You may have to modify the code to work with specified wrapping modes and widths of your controls.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com



_______________________________________________ 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
References: 
 >Part of an NSAttributedString that fir a rectangle ? (From: Eric Morand <email@hidden>)
 >Re: Part of an NSAttributedString that fir a rectangle ? (From: Ricky Sharp <email@hidden>)

  • Prev by Date: drag-removing nsstatusitems from menubar
  • Next by Date: NSOutlineView selectable only children
  • Previous by thread: Re: Part of an NSAttributedString that fir a rectangle ?
  • Next by thread: NSBrowser & Binding
  • Index(es):
    • Date
    • Thread