修复字体变粗后不能变细的bug

pull/1395/head
gedoor 3 years ago
parent bae7094a79
commit aad56ae01d
  1. 35
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -85,10 +85,10 @@ object ChapterProvider {
private set private set
@JvmStatic @JvmStatic
val titlePaint: TextPaint = TextPaint() var titlePaint: TextPaint = TextPaint()
@JvmStatic @JvmStatic
val contentPaint: TextPaint = TextPaint() var contentPaint: TextPaint = TextPaint()
var doublePage = false var doublePage = false
private set private set
@ -500,7 +500,10 @@ object ChapterProvider {
*/ */
fun upStyle() { fun upStyle() {
typeface = getTypeface(ReadBookConfig.textFont) typeface = getTypeface(ReadBookConfig.textFont)
upPaint(typeface) getPaint(typeface).let {
titlePaint = it.first
contentPaint = it.second
}
//间距 //间距
lineSpacingExtra = ReadBookConfig.lineSpacingExtra lineSpacingExtra = ReadBookConfig.lineSpacingExtra
paragraphSpacing = ReadBookConfig.paragraphSpacing paragraphSpacing = ReadBookConfig.paragraphSpacing
@ -535,7 +538,7 @@ object ChapterProvider {
} ?: Typeface.DEFAULT } ?: Typeface.DEFAULT
} }
private fun upPaint(typeface: Typeface) { private fun getPaint(typeface: Typeface): Pair<TextPaint, TextPaint> {
// 字体统一处理 // 字体统一处理
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)
@ -556,17 +559,19 @@ object ChapterProvider {
} }
//标题 //标题
titlePaint.color = ReadBookConfig.textColor val tPaint = TextPaint()
titlePaint.letterSpacing = ReadBookConfig.letterSpacing tPaint.color = ReadBookConfig.textColor
titlePaint.typeface = titleFont tPaint.letterSpacing = ReadBookConfig.letterSpacing
titlePaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat() tPaint.typeface = titleFont
titlePaint.isAntiAlias = true tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
//正文 tPaint.isAntiAlias = true
contentPaint.color = ReadBookConfig.textColor val cPaint = TextPaint()
contentPaint.letterSpacing = ReadBookConfig.letterSpacing cPaint.color = ReadBookConfig.textColor
contentPaint.typeface = textFont cPaint.letterSpacing = ReadBookConfig.letterSpacing
contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() cPaint.typeface = textFont
contentPaint.isAntiAlias = true cPaint.textSize = ReadBookConfig.textSize.sp.toFloat()
cPaint.isAntiAlias = true
return Pair(tPaint, cPaint)
} }
/** /**

Loading…
Cancel
Save