This commit is contained in:
Horis
2024-12-23 21:17:48 +08:00
parent 951aa242e0
commit fe78cdc561
@@ -342,34 +342,23 @@ class TextChapterLayout(
} }
Book.imgStyleSingle -> { Book.imgStyleSingle -> {
width = ChapterProvider.visibleWidth width = visibleWidth
height = size.height * ChapterProvider.visibleWidth / size.width height = size.height * visibleWidth / size.width
if (height > ChapterProvider.visibleHeight) { if (height > visibleHeight) {
width = width * ChapterProvider.visibleHeight / height width = width * visibleHeight / height
height = ChapterProvider.visibleHeight height = visibleHeight
} }
if (durY > 0f) { if (durY > 0f) {
val textPage = pendingTextPage val textPage = pendingTextPage
// 双页的 durY 不正确,可能会小于实际高度
if (textPage.height < durY) { if (textPage.height < durY) {
textPage.height = durY textPage.height = durY
} }
if (doublePage && absStartX < viewWidth / 2) { textPage.text = stringBuilder.toString().ifEmpty { "本页无文字内容" }
//当前页面左列结束 stringBuilder.clear()
textPage.leftLineSize = textPage.lineSize textPages.add(textPage)
absStartX = viewWidth / 2 + paddingLeft coroutineContext.ensureActive()
} else { onPageCompleted()
//当前页面结束 pendingTextPage = TextPage()
if (textPage.leftLineSize == 0) {
textPage.leftLineSize = textPage.lineSize
}
textPage.text = stringBuilder.toString().ifEmpty { "本页无文字内容" }
stringBuilder.clear()
textPages.add(textPage)
coroutineContext.ensureActive()
onPageCompleted()
pendingTextPage = TextPage()
}
durY = 0f durY = 0f
} }
} }