mirror of
https://github.com/gedoor/legado.git
synced 2025-01-07 03:06:58 +08:00
优化
This commit is contained in:
parent
f5ce657d1d
commit
242af576a5
@ -845,7 +845,11 @@ object ChapterProvider {
|
||||
titleTopSpacing = ReadBookConfig.titleTopSpacing.dpToPx()
|
||||
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dpToPx()
|
||||
val bodyIndent = ReadBookConfig.paragraphIndent
|
||||
indentCharWidth = StaticLayout.getDesiredWidth(bodyIndent, contentPaint) / bodyIndent.length
|
||||
var indentWidth = StaticLayout.getDesiredWidth(bodyIndent, contentPaint)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
indentWidth += contentPaint.letterSpacing * contentPaint.textSize
|
||||
}
|
||||
indentCharWidth = indentWidth / bodyIndent.length
|
||||
titlePaintTextHeight = titlePaint.textHeight
|
||||
contentPaintTextHeight = contentPaint.textHeight
|
||||
titlePaintFontMetrics = titlePaint.fontMetrics
|
||||
|
@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page.provider
|
||||
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Rect
|
||||
import android.os.Build
|
||||
import android.text.Layout
|
||||
import android.text.TextPaint
|
||||
import java.util.WeakHashMap
|
||||
@ -216,7 +217,13 @@ class ZhLayout(
|
||||
return cnCharWidth / 2 - d
|
||||
}
|
||||
|
||||
fun getDesiredWidth(sting: String, paint: TextPaint) = paint.measureText(sting)
|
||||
fun getDesiredWidth(string: String, paint: TextPaint): Float {
|
||||
var width = paint.measureText(string)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
width += paint.letterSpacing * paint.textSize
|
||||
}
|
||||
return width
|
||||
}
|
||||
|
||||
override fun getLineCount(): Int {
|
||||
return lineCount
|
||||
|
Loading…
Reference in New Issue
Block a user