优化
This commit is contained in:
@@ -350,13 +350,13 @@ object ChapterProvider {
|
|||||||
srcList: LinkedList<String>? = null
|
srcList: LinkedList<String>? = null
|
||||||
): Pair<Int, Float> {
|
): Pair<Int, Float> {
|
||||||
var absStartX = x
|
var absStartX = x
|
||||||
|
val widthsArray = FloatArray(text.length)
|
||||||
val layout = if (ReadBookConfig.useZhLayout) {
|
val layout = if (ReadBookConfig.useZhLayout) {
|
||||||
ZhLayout(text, textPaint, visibleWidth)
|
ZhLayout(text, textPaint, visibleWidth, widthsArray)
|
||||||
} else {
|
} else {
|
||||||
|
textPaint.getTextWidths(text, widthsArray)
|
||||||
StaticLayout(text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true)
|
StaticLayout(text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true)
|
||||||
}
|
}
|
||||||
val widthsArray = FloatArray(text.length)
|
|
||||||
textPaint.getTextWidths(text, widthsArray)
|
|
||||||
val widthsList = widthsArray.asList()
|
val widthsList = widthsArray.asList()
|
||||||
var durY = when {
|
var durY = when {
|
||||||
//标题y轴居中
|
//标题y轴居中
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ import kotlin.math.max
|
|||||||
class ZhLayout(
|
class ZhLayout(
|
||||||
text: CharSequence,
|
text: CharSequence,
|
||||||
textPaint: TextPaint,
|
textPaint: TextPaint,
|
||||||
width: Int
|
width: Int,
|
||||||
|
widthsArray: FloatArray
|
||||||
) : Layout(text, textPaint, width, Alignment.ALIGN_NORMAL, 0f, 0f) {
|
) : Layout(text, textPaint, width, Alignment.ALIGN_NORMAL, 0f, 0f) {
|
||||||
companion object {
|
companion object {
|
||||||
private val postPanc = hashSetOf(
|
private val postPanc = hashSetOf(
|
||||||
@@ -43,7 +44,6 @@ class ZhLayout(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
var line = 0
|
var line = 0
|
||||||
val widthsArray = FloatArray(text.length)
|
|
||||||
curPaint.getTextWidths(text as String, widthsArray)
|
curPaint.getTextWidths(text as String, widthsArray)
|
||||||
val (words, widths) = ChapterProvider.getStringArrayAndTextWidths(
|
val (words, widths) = ChapterProvider.getStringArrayAndTextWidths(
|
||||||
text,
|
text,
|
||||||
|
|||||||
Reference in New Issue
Block a user