pull/1352/head
gedoor 3 years ago
parent 1d04dea4ac
commit 88f757c21c
  1. 34
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -66,10 +66,10 @@ object ChapterProvider {
var typeface: Typeface = Typeface.DEFAULT var typeface: Typeface = Typeface.DEFAULT
@JvmStatic @JvmStatic
lateinit var titlePaint: TextPaint val titlePaint: TextPaint = TextPaint()
@JvmStatic @JvmStatic
lateinit var contentPaint: TextPaint val contentPaint: TextPaint = TextPaint()
private const val srcReplaceChar = "" private const val srcReplaceChar = ""
@ -453,10 +453,7 @@ object ChapterProvider {
*/ */
fun upStyle() { fun upStyle() {
typeface = getTypeface(ReadBookConfig.textFont) typeface = getTypeface(ReadBookConfig.textFont)
getPaint(typeface).let { upPaint(typeface)
titlePaint = it.first
contentPaint = it.second
}
//间距 //间距
lineSpacingExtra = ReadBookConfig.lineSpacingExtra lineSpacingExtra = ReadBookConfig.lineSpacingExtra
paragraphSpacing = ReadBookConfig.paragraphSpacing paragraphSpacing = ReadBookConfig.paragraphSpacing
@ -491,7 +488,7 @@ object ChapterProvider {
} ?: Typeface.DEFAULT } ?: Typeface.DEFAULT
} }
private fun getPaint(typeface: Typeface): Pair<TextPaint, TextPaint> { private fun upPaint(typeface: Typeface) {
// 字体统一处理 // 字体统一处理
val bold = Typeface.create(typeface, Typeface.BOLD) val bold = Typeface.create(typeface, Typeface.BOLD)
val normal = Typeface.create(typeface, Typeface.NORMAL) val normal = Typeface.create(typeface, Typeface.NORMAL)
@ -512,20 +509,17 @@ object ChapterProvider {
} }
//标题 //标题
val tPaint = TextPaint() titlePaint.color = ReadBookConfig.textColor
tPaint.color = ReadBookConfig.textColor titlePaint.letterSpacing = ReadBookConfig.letterSpacing
tPaint.letterSpacing = ReadBookConfig.letterSpacing titlePaint.typeface = titleFont
tPaint.typeface = titleFont titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() titlePaint.isAntiAlias = true
tPaint.isAntiAlias = true
//正文 //正文
val cPaint = TextPaint() contentPaint.color = ReadBookConfig.textColor
cPaint.color = ReadBookConfig.textColor contentPaint.letterSpacing = ReadBookConfig.letterSpacing
cPaint.letterSpacing = ReadBookConfig.letterSpacing contentPaint.typeface = textFont
cPaint.typeface = textFont contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat()
cPaint.textSize = ReadBookConfig.textSize.sp.toFloat() contentPaint.isAntiAlias = true
cPaint.isAntiAlias = true
return Pair(tPaint, cPaint)
} }
/** /**

Loading…
Cancel
Save