This commit is contained in:
Horis
2023-10-02 13:35:17 +08:00
parent 318ff762fa
commit bf0e45fdef
2 changed files with 5 additions and 5 deletions

View File

@@ -350,13 +350,13 @@ object ChapterProvider {
srcList: LinkedList<String>? = null
): Pair<Int, Float> {
var absStartX = x
val widthsArray = FloatArray(text.length)
val layout = if (ReadBookConfig.useZhLayout) {
ZhLayout(text, textPaint, visibleWidth)
ZhLayout(text, textPaint, visibleWidth, widthsArray)
} else {
textPaint.getTextWidths(text, widthsArray)
StaticLayout(text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true)
}
val widthsArray = FloatArray(text.length)
textPaint.getTextWidths(text, widthsArray)
val widthsList = widthsArray.asList()
var durY = when {
//标题y轴居中

View File

@@ -13,7 +13,8 @@ import kotlin.math.max
class ZhLayout(
text: CharSequence,
textPaint: TextPaint,
width: Int
width: Int,
widthsArray: FloatArray
) : Layout(text, textPaint, width, Alignment.ALIGN_NORMAL, 0f, 0f) {
companion object {
private val postPanc = hashSetOf(
@@ -43,7 +44,6 @@ class ZhLayout(
init {
var line = 0
val widthsArray = FloatArray(text.length)
curPaint.getTextWidths(text as String, widthsArray)
val (words, widths) = ChapterProvider.getStringArrayAndTextWidths(
text,