mirror of
https://github.com/gedoor/legado.git
synced 2025-01-09 04:17:45 +08:00
优化
This commit is contained in:
parent
f5ce657d1d
commit
242af576a5
@ -845,7 +845,11 @@ object ChapterProvider {
|
|||||||
titleTopSpacing = ReadBookConfig.titleTopSpacing.dpToPx()
|
titleTopSpacing = ReadBookConfig.titleTopSpacing.dpToPx()
|
||||||
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dpToPx()
|
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dpToPx()
|
||||||
val bodyIndent = ReadBookConfig.paragraphIndent
|
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
|
titlePaintTextHeight = titlePaint.textHeight
|
||||||
contentPaintTextHeight = contentPaint.textHeight
|
contentPaintTextHeight = contentPaint.textHeight
|
||||||
titlePaintFontMetrics = titlePaint.fontMetrics
|
titlePaintFontMetrics = titlePaint.fontMetrics
|
||||||
|
@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page.provider
|
|||||||
|
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
|
import android.os.Build
|
||||||
import android.text.Layout
|
import android.text.Layout
|
||||||
import android.text.TextPaint
|
import android.text.TextPaint
|
||||||
import java.util.WeakHashMap
|
import java.util.WeakHashMap
|
||||||
@ -216,7 +217,13 @@ class ZhLayout(
|
|||||||
return cnCharWidth / 2 - d
|
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 {
|
override fun getLineCount(): Int {
|
||||||
return lineCount
|
return lineCount
|
||||||
|
Loading…
Reference in New Issue
Block a user