feat: complete large-book pagination runtime and UI coverage
This commit is contained in:
@@ -146,6 +146,10 @@ struct RDEPUBChapterPageCounter {
|
||||
var frames: [RDEPUBTextLayoutFrame] = []
|
||||
var location = 0
|
||||
let pageRect = dtLayoutRect
|
||||
let isDebug = ProcessInfo.processInfo.arguments.contains("--demo-pagination-debug")
|
||||
if isDebug {
|
||||
print("[PAGINATION-DEBUG] pageRect=\(pageRect) totalLength=\(attributedString.length)")
|
||||
}
|
||||
|
||||
while location < attributedString.length {
|
||||
guard let layoutFrame = layouter.layoutFrame(with: pageRect, range: NSRange(location: location, length: 0)) else {
|
||||
@@ -165,6 +169,16 @@ struct RDEPUBChapterPageCounter {
|
||||
proposed: lineAdjusted,
|
||||
lineRanges: lineRanges
|
||||
)
|
||||
|
||||
if isDebug {
|
||||
let pageCount = frames.count + 1
|
||||
let previewText = (attributedString.string as NSString).substring(with: NSRange(location: location, length: min(20, attributedString.length - location)))
|
||||
let avoidRemoved = proposedRange.length - avoidAdjusted.length
|
||||
let kwNextRemoved = avoidAdjusted.length - lineAdjusted.length
|
||||
let widowRemoved = lineAdjusted.length - widowOrphanAdjusted.length
|
||||
let totalRemoved = proposedRange.length - widowOrphanAdjusted.length
|
||||
print("[PAGINATION-DEBUG] page#\(pageCount) loc=\(location) proposed=\(proposedRange.length) avoid(-\(avoidRemoved)) kwNext(-\(kwNextRemoved)) widowOrphan(-\(widowRemoved)) total(-\(totalRemoved)) lastLine=\"\(previewText)\"")
|
||||
}
|
||||
let effectiveLineRanges = lineRangesWithinRange(lineRanges, range: widowOrphanAdjusted)
|
||||
let adjusted = pageBreakPolicy.adjustedRange(
|
||||
from: widowOrphanAdjusted,
|
||||
|
||||
Reference in New Issue
Block a user