On May 20, 2013, at 7:26 AM, Gideon King <gid...@novamind.com> wrote:
> Hi, I have inherited some code which has a subclass of NSATSTypesetter in it, > and in the -willSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset: > method it works out whether it needs to put a page break in, and directly > sets the currentTextContainer, currentTextContainerIndex, and > currentTextContainerSize instance variables. > > This is completely undocumented and presumably a very bad way to handle the > pagination, so I want to fix it. > > The problem is that I am not clear whether the typesetter is the place to do > the pagination or whether it should be in the layout manager, and if so > exactly how to handle the processing. Any advice on how best to handle the > pagination would be most welcome. The typesetter should be performing pagination, somewhere within or below -layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments: nextGlyphIndex: in the call stack. One hint that this is true is in the documentation for -[NSLayoutManager setTextContainer:forGlyphRange:], which notes that it should only be called by the typesetter during layout. As for actually keeping track of which text container you're laying into, you're right that accessing those ivars directly is bad form. If you'd like to avoid direct ivar access, add your own ivars that mimic the existing ones and override -currentTextContainer to use them. Then file a radar asking for -[NSTypesetter setCurrentTextContainerIndex:] for use by subclasses. (I haven't spent the time thinking about whether -willSetLineFragmentarect:… is the appropriate place to do pagination.) --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com