Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Oct 2, 2023
1 parent 318ff76 commit bf0e45f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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轴居中
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bf0e45f

Please sign in to comment.