From aad56ae01dccc9c2f54c871ff9a2a3a3fdec30e8 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 2 Oct 2021 20:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E4=BD=93=E5=8F=98?= =?UTF-8?q?=E7=B2=97=E5=90=8E=E4=B8=8D=E8=83=BD=E5=8F=98=E7=BB=86=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../read/page/provider/ChapterProvider.kt | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 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 d3d5c8295..ca948ff0c 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 @@ -85,10 +85,10 @@ object ChapterProvider { private set @JvmStatic - val titlePaint: TextPaint = TextPaint() + var titlePaint: TextPaint = TextPaint() @JvmStatic - val contentPaint: TextPaint = TextPaint() + var contentPaint: TextPaint = TextPaint() var doublePage = false private set @@ -500,7 +500,10 @@ object ChapterProvider { */ fun upStyle() { typeface = getTypeface(ReadBookConfig.textFont) - upPaint(typeface) + getPaint(typeface).let { + titlePaint = it.first + contentPaint = it.second + } //间距 lineSpacingExtra = ReadBookConfig.lineSpacingExtra paragraphSpacing = ReadBookConfig.paragraphSpacing @@ -535,7 +538,7 @@ object ChapterProvider { } ?: Typeface.DEFAULT } - private fun upPaint(typeface: Typeface) { + private fun getPaint(typeface: Typeface): Pair { // 字体统一处理 val bold = Typeface.create(typeface, Typeface.BOLD) val normal = Typeface.create(typeface, Typeface.NORMAL) @@ -556,17 +559,19 @@ object ChapterProvider { } //标题 - titlePaint.color = ReadBookConfig.textColor - titlePaint.letterSpacing = ReadBookConfig.letterSpacing - titlePaint.typeface = titleFont - titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() - titlePaint.isAntiAlias = true - //正文 - contentPaint.color = ReadBookConfig.textColor - contentPaint.letterSpacing = ReadBookConfig.letterSpacing - contentPaint.typeface = textFont - contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() - contentPaint.isAntiAlias = true + val tPaint = TextPaint() + tPaint.color = ReadBookConfig.textColor + tPaint.letterSpacing = ReadBookConfig.letterSpacing + tPaint.typeface = titleFont + tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() + tPaint.isAntiAlias = true + val cPaint = TextPaint() + cPaint.color = ReadBookConfig.textColor + cPaint.letterSpacing = ReadBookConfig.letterSpacing + cPaint.typeface = textFont + cPaint.textSize = ReadBookConfig.textSize.sp.toFloat() + cPaint.isAntiAlias = true + return Pair(tPaint, cPaint) } /**