• 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: Custom line breaking in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom line breaking in NSTextView


  • Subject: Re: Custom line breaking in NSTextView
  • From: email@hidden (Stefan Haller)
  • Date: Wed, 27 Jul 2005 11:00:41 +0200
  • Organization: Ableton

Thanks for the suggestion, but I don't think this is what I need.

As I see it, there are two decisions to be made during the layout
process:

1) Determine which is the first character that no longer fits on the
   current line;

2) Once that character is found, go back from there and look for a
   suitable place where to break the line.

Your suggestion would allow me to customize 2), which is not what I
want; I need to customize 1).

I did a few quick experiments with layoutGlyphsInLayoutManager, and it
does look like it would allow me to do what I need; however, I would
have to reimplement much of what the original method already does, such
as combining glyphs into ligatures, handling tabs, dealing with text
attachments, and probably much more, so I'm still looking for a better
(easier) solution.


Aki Inoue <email@hidden> wrote:

> The bottleneck for line breaking for the Text System is -
> [NSAttributedString lineBreakBeforeIndex:withinRange:].  You can
> implement a subclass of NSTextStorage and override this method to
> have custom behavior.
>
> Aki
>
> > (I seem to remember that this has been discussed before, a couple of
> > years ago, but without a satisfactory solution; and I can't find the
> > thread in the archives right now.)
> >
> >
> > I would like to customize the line breaking in an NSTextView in such a
> > way that it doesn't wrap at the window width, but after a certain
> > number
> > of characters, say 72.  Any suggestions how to go about this?
> >
> > I suspect that one solution might be to sub-class NSATSTypesetter and
> > override
> >
> >    layoutGlyphsInLayoutManager:
> >       startingAtGlyphIndex:
> >       maxNumberOfLineFragments:
> >       nextGlyphIndex:
> >
> > but that seems like a lot of work to me (if I can figure out at all
> > what
> > exactly I have to do in my overridden method).
> >
> > Any pointers (especially at sample code) would be much appreciated.
> >
> >
> > --
> > Stefan Haller
> > Ableton
> > http://www.ableton.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
> >


--
Stefan Haller
Ableton
http://www.ableton.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

  • Follow-Ups:
    • Re: Custom line breaking in NSTextView
      • From: Aki Inoue <email@hidden>
References: 
 >Re: Custom line breaking in NSTextView (From: Aki Inoue <email@hidden>)

  • Prev by Date: Re: Localized number formatting
  • Next by Date: Re: Window Closing Behavior
  • Previous by thread: Re: Custom line breaking in NSTextView
  • Next by thread: Re: Custom line breaking in NSTextView
  • Index(es):
    • Date
    • Thread