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) } /**