My book to app framework is designed to produce 'book apps' simply by swapping new content into a reusable structure. Built with Flutter, TextPainter proved too unreliable for fitting hundreds of words into the available space on a phone screen. I use a method that incrementally fills the available space until it might be overfilled, providing content does not run out, and then backtracks a word or two to find the exact page boundary.
The current code is tuned for reliability rather than raw speed, but in practice it still paginates at roughly 1000 words per second, device dependent.