• 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: Forcing typesetter to advance to next text container
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Forcing typesetter to advance to next text container


  • Subject: Re: Forcing typesetter to advance to next text container
  • From: Aram Greenman <email@hidden>
  • Date: Tue, 6 Jul 2004 21:27:58 -0700

On Jul 5, 2004, at 1:30 PM, Aki Inoue wrote:

If all of your text containers have the same width & line fragment padding, you can just update currentTextContainer, currentTextContainerIndex, and currentTextContainerSize ivars (you also need to move the line fragment y origin to the container origin).

That worked, thanks a lot. For anyone else reading this thread, these settings:
currentTextContainer = nil;
currentTextContainerIndex = NSNotFound;
currentTextContainerSize = NSZeroSize;
will cause the typesetter to stop layout and tell the layout manager it's out of text containers, or at least that's how it seems to work for me ;-)


Unfortunately, there is no way to cancel the current paragraph layout in the middle. So, if the new text container has a different layout area from the current, you have to restart by tweaking -layoutParagraphAtPoint:. SInce I received a couple requests for rejecting the current line layout at WWDC, I'm considering to add such functionality in a future release.

For this project, all my container breaks will occur at paragraph separators, so it's not a problem, but I agree that having the ability to reject layout would be a good idea, since it's possible that the layout of a section of text would depend on how text that follows it is laid out.

Personally I'd like to be able to either a) backtrack to any point in the text, not just the current line, or b) "preview" the layout to a later point in the text and accept or reject it. I'm not sure how this should be implemented API-wise but that's my general concept. Once I'm farther along with this project and have a clearer idea how this should work I'll file a bug report.

The reason I could use this is that I can't have container breaks at certain points in my text. If the typesetter is about to insert a container break where I don't want one, then I move a range of text to the next text container. Right now the way I'm predicting where the typesetter is going to put the container breaks is to use a second layout manager to "look ahead" and calculate the approximate height of a substring of the text, up to the point where I would allow a container break again. The problem is this is at least twice as slow as just laying the text out normally, and the amount of text I actually have to tweak the layout on is minimal. If there was some way to cache the "previewed" layout, I could reduce the amount of text that has to be laid out twice by about 80%.

Thanks,

Aram



On 2004/07/05, at 2:31, Aram Greenman wrote:

I have a text system which uses a series of text containers sharing the same layout manager. During the layout phase, at certain glyphs I want to move to the next text container even if the current text container has room left.

I thought overriding -[NSATSTypesetter willSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:] to zero out the the line fragment rect would do this, but this just makes the typesetter think the glyphs will actually fit in a zero rect and messes up the layout.

Basically, here's what I want my typesetter to do, but -advanceToNextTextContainer and -restartLayoutFromGlyphIndex: don't exist ;-)
Any ideas are greatly appreciated, I'm stumped on this one.

@implementation MyATSTypesetter

- (void)willSetLineFragmentRect:(NSRect *)lineRect
forGlyphRange:(NSRange)glyphRange
usedRect:(NSRect *)usedRect
baselineOffset:(float *)baselineOffset
{
if (glyphRange.location == someNumber) {
[self advanceToNextTextContainer];
[self restartLayoutFromGlyphIndex:glyphRange.location];
}
}

@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Forcing typesetter to advance to next text container (From: Aram Greenman <email@hidden>)
 >Re: Forcing typesetter to advance to next text container (From: Aki Inoue <email@hidden>)

  • Prev by Date: Re: FTP upload
  • Next by Date: Detecting user activity
  • Previous by thread: Re: Forcing typesetter to advance to next text container
  • Next by thread: NSBoxSeparator in NSTextField
  • Index(es):
    • Date
    • Thread