• 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
NSLayoutManager/NSTypesetter ignoring paragraphSpacingBefore
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSLayoutManager/NSTypesetter ignoring paragraphSpacingBefore


  • Subject: NSLayoutManager/NSTypesetter ignoring paragraphSpacingBefore
  • From: Steve Shepard <email@hidden>
  • Date: Thu, 25 Aug 2005 17:58:03 -0700

I'm trying to work around the fact that NSLayoutManager ignores the
NSParagraphStyle paragraphSpacingBefore property for the first
paragraph in a container.

My approach is to subclass NSATSTypesetter and override as follows:

- (float)paragraphSpacingBeforeGlyphAtIndex:(unsigned)glyphIndex
withProposedLineFragmentRect:(NSRect)rect
{
    float spacing;

    if (glyphIndex == 0) {

        unsigned charIndex = [layoutManager
characterIndexForGlyphAtIndex:glyphIndex];

        if (charIndex < [[self attributedString] length]) {

            NSParagraphStyle *style = [[self attributedString]
attribute:NSParagraphStyleAttributeName atIndex:charIndex
effectiveRange:nil];
            spacing = [style paragraphSpacingBefore];
        } else {
            spacing = [super
paragraphSpacingBeforeGlyphAtIndex:glyphIndex
withProposedLineFragmentRect:rect];
        }

    } else {
        spacing = [super paragraphSpacingBeforeGlyphAtIndex:glyphIndex
withProposedLineFragmentRect:rect];
    }

    return spacing;

}

This works for most cases. However, there seems to be another path
through the layout code that doesn't call this method, e.g. when text
is pasted at the top of a container or in live resize when the text
contains NSTextBlocks.

What am I missing?

-Steve
 _______________________________________________
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

  • Prev by Date: Re: How to draw correct underline ?
  • Next by Date: Re: Getting one sheet to open after another
  • Previous by thread: RE: Getting one sheet to open after another
  • Next by thread: Spotlight enabling of Preference Panel
  • Index(es):
    • Date
    • Thread