Page-based layouts with TextKit 2?

In the "old" TextKit, page-based layout is accomplished by providing an array of NSTextContainers to NSLayoutManager, each with its own NSTextView.

TextKit 2, NSTextLayoutManager allows only a single text container. Additionally, NSTextParagraph seems to be the only concrete NSTextElement class. Paragraphs often need to break across page boundaries.

How would one implement page-based layout in TextKit 2?

Replies

Hi there,

This functionality is not available in macOS Monterey Beta 1. We understand that this is an important issue for many developers and we are actively investigating the issue. If you'd like, you can file a Feedback Assistant to stay updated on the status of the issue.

Thanks for your patience!

  • Feedback submitted as FB9285387: TextKit 2 missing support for page-based layout

    TextKit 2 was introduced at WWDC21 as "Apple's next-generation text engine" that has been in use on macOS since Big Sur. The new engine looks promising, but unfortunately, it is missing support for page-based layout. This is a critical feature, the omission of which will adversely affect a wide range of applications.

    In the "old" TextKit, page-based layout is accomplished by providing an array of NSTextContainers to NSLayoutManager, each with its own NSTextView. The process is described in Using Text Kit to Draw and Manage Text and in the widely distributed sample code for TextEdit.

    In TextKit 2, NSTextLayoutManager allows only a single NSTextContainer, making it impossible to support more than one page of text.

    To achieve better feature parity with the "old" TextKit, TextKit 2 should be enhanced to support page-based layout.

  • This seems like a pretty well documented and important capability to remove. A severe regression. I tried to port a very old piece of sample code to TextKit 2 (https://developer.apple.com/library/archive/samplecode/TextLayoutDemo/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004341). I was really surprised that it wasn't possible to replicate the 2-column demo because of this regression.

  • Is there any additional information on this? Monterey is now RC and FB9285387 is still open with no similar reports. The lack of this feature would cripple my app, which has been on Mac since 2007. I think many developers would appreciate guidance here, even if it's just a commitment on how long Apple will maintain TextKit 1.

Hi, Do you know when this functionality will appear?

Wonder, how did they provide pagination with Text Kit 2 in TextEdit app? As they said in the What's new in AppKit session, TextEdit uses Text Kit 2 since macOS Big Sur.

  • TextEdit on Big Sur does not use TextKit 2 for "Wrap to Page." As noted above by the Frameworks Engineer, the functionality is not available in TextKit 2.

Add a Comment

I'm looking for this too. It seems like a glaring oversight. Feedback submitted.