From bf0e45fdef9c086e7f2eeb7e66ed58550d6ced7c Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Mon, 2 Oct 2023 13:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/provider/ChapterProvider.kt | 6 +++--- .../io/legado/app/ui/book/read/page/provider/ZhLayout.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index b8eb5acce988..c4d3138ad814 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -350,13 +350,13 @@ object ChapterProvider { srcList: LinkedList? = null ): Pair { var absStartX = x + val widthsArray = FloatArray(text.length) val layout = if (ReadBookConfig.useZhLayout) { - ZhLayout(text, textPaint, visibleWidth) + ZhLayout(text, textPaint, visibleWidth, widthsArray) } else { + textPaint.getTextWidths(text, widthsArray) StaticLayout(text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true) } - val widthsArray = FloatArray(text.length) - textPaint.getTextWidths(text, widthsArray) val widthsList = widthsArray.asList() var durY = when { //标题y轴居中 diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ZhLayout.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ZhLayout.kt index fd06e3768330..1e9105ccda16 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ZhLayout.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ZhLayout.kt @@ -13,7 +13,8 @@ import kotlin.math.max class ZhLayout( text: CharSequence, textPaint: TextPaint, - width: Int + width: Int, + widthsArray: FloatArray ) : Layout(text, textPaint, width, Alignment.ALIGN_NORMAL, 0f, 0f) { companion object { private val postPanc = hashSetOf( @@ -43,7 +44,6 @@ class ZhLayout( init { var line = 0 - val widthsArray = FloatArray(text.length) curPaint.getTextWidths(text as String, widthsArray) val (words, widths) = ChapterProvider.getStringArrayAndTextWidths( text,