diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 71f337198..3366c019d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -124,15 +124,7 @@ object ChapterProvider { //中间行 addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } - if (durY + textPaint.textHeight < visibleHeight) { - //当前页面新增行 - stringBuilder.append(words) - if (isLastLine) stringBuilder.append("\n") - textLine.upTopBottom(durY, textPaint) - textPages.last().textLines.add(textLine) - durY += textPaint.textHeight * lineSpacingExtra / 10f - textPages.last().height = durY - } else { + if (durY + textPaint.textHeight > visibleHeight) { //当前页面结束,设置各种值 textPages.last().text = stringBuilder.toString() pageLines.add(textPages.last().textLines.size) @@ -141,13 +133,14 @@ object ChapterProvider { //新建页面 textPages.add(TextPage()) stringBuilder.clear() - stringBuilder.append(words) - if (isLastLine) stringBuilder.append("\n") - textLine.upTopBottom(0f, textPaint) - textPages.last().textLines.add(textLine) - durY = textPaint.textHeight * lineSpacingExtra / 10f - textPages.last().height = durY + durY = 0f } + stringBuilder.append(words) + if (isLastLine) stringBuilder.append("\n") + textPages.last().textLines.add(textLine) + textLine.upTopBottom(durY, textPaint) + durY += textPaint.textHeight * lineSpacingExtra / 10f + textPages.last().height = durY } durY += textPaint.textHeight * paragraphSpacing / 10f return durY