This commit is contained in:
Horis
2024-08-22 14:18:39 +08:00
parent bc8052fde9
commit b02e95fa07
2 changed files with 6 additions and 8 deletions
@@ -326,7 +326,8 @@ data class TextPage(
fun render(view: ContentTextView): Boolean { fun render(view: ContentTextView): Boolean {
if (!isCompleted) return false if (!isCompleted) return false
return canvasRecorder.recordIfNeeded(view.width, height.toInt() + paddingTop) { val height = lines.lastOrNull()?.lineBottom?.toInt() ?: 0
return canvasRecorder.recordIfNeeded(view.width, height) {
drawPage(view, this) drawPage(view, this)
} }
} }
@@ -33,7 +33,6 @@ import kotlinx.coroutines.launch
import java.util.LinkedList import java.util.LinkedList
import java.util.Locale import java.util.Locale
import kotlin.coroutines.coroutineContext import kotlin.coroutines.coroutineContext
import kotlin.math.max
import kotlin.math.roundToInt import kotlin.math.roundToInt
class TextChapterLayout( class TextChapterLayout(
@@ -447,9 +446,8 @@ class TextChapterLayout(
val textLine = TextLine(isTitle = isTitle) val textLine = TextLine(isTitle = isTitle)
if (durY + textHeight > visibleHeight) { if (durY + textHeight > visibleHeight) {
val textPage = pendingTextPage val textPage = pendingTextPage
val height = max(durY, textPage.lines.lastOrNull()?.lineBottom ?: 0f) if (textPage.height < durY) {
if (textPage.height < height) { textPage.height = durY
textPage.height = height
} }
if (doublePage && absStartX < viewWidth / 2) { if (doublePage && absStartX < viewWidth / 2) {
//当前页面左列结束 //当前页面左列结束
@@ -532,9 +530,8 @@ class TextChapterLayout(
val textPage = pendingTextPage val textPage = pendingTextPage
textPage.addLine(textLine) textPage.addLine(textLine)
durY += textHeight * lineSpacingExtra durY += textHeight * lineSpacingExtra
val height = max(durY, textPage.lines.lastOrNull()?.lineBottom ?: 0f) if (textPage.height < durY) {
if (textPage.height < height) { textPage.height = durY
textPage.height = height
} }
} }
durY += textHeight * paragraphSpacing / 10f durY += textHeight * paragraphSpacing / 10f