feat(epub): align text rendering with WXRead

This commit is contained in:
shen
2026-05-24 09:56:32 +08:00
parent 5125b8de51
commit a318c0e3d0
13 changed files with 1556 additions and 135 deletions
@@ -46,6 +46,7 @@ public final class RDPlainTextBookBuilder {
: layoutFrames
let href = "chapter_\(index).xhtml"
let chapterAttributedContent = content.copy() as! NSAttributedString
let pages = effectiveFrames.enumerated().map { localPageIndex, frame in
let range = frame.contentRange
return RDEPUBTextPage(
@@ -56,6 +57,7 @@ public final class RDPlainTextBookBuilder {
chapterTitle: spec.title ?? "\(index + 1)",
pageIndexInChapter: localPageIndex,
totalPagesInChapter: effectiveFrames.count,
chapterContent: chapterAttributedContent,
content: content.attributedSubstring(from: range),
contentRange: range,
pageStartOffset: range.location,
@@ -70,7 +72,7 @@ public final class RDPlainTextBookBuilder {
spineIndex: index,
href: href,
title: spec.title ?? "\(index + 1)",
attributedContent: content.copy() as! NSAttributedString,
attributedContent: chapterAttributedContent,
fragmentOffsets: [:],
pageBreakReasons: pages.map { $0.metadata.breakReason },
pages: pages