pull/885/head^2
gedoor 4 years ago
parent dabb66018f
commit 7df8206eb6
  1. 18
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ZhLayout.kt

@ -7,11 +7,10 @@ import android.text.TextPaint
import io.legado.app.utils.toStringArray import io.legado.app.utils.toStringArray
import kotlin.math.max import kotlin.math.max
/* /**
* 针对中文的断行排版处理-by hoodie13 * 针对中文的断行排版处理-by hoodie13
* 因为StaticLayout对标点处理不符合国人习惯继承Layout * 因为StaticLayout对标点处理不符合国人习惯继承Layout
* 接口封的不抽象数组用的也琐碎因目前语法不熟悉后面完善 * */
* */
@Suppress("MemberVisibilityCanBePrivate", "unused") @Suppress("MemberVisibilityCanBePrivate", "unused")
class ZhLayout( class ZhLayout(
text: String, text: String,
@ -145,8 +144,7 @@ class ZhLayout(
if (breakLine) { if (breakLine) {
lineWidth[line] = lineW - offset lineWidth[line] = lineW - offset
lineW = offset lineW = offset
line++ addLineArray(++line)
addLineArray(line)
} }
/*已到最后一个字符*/ /*已到最后一个字符*/
if ((words.lastIndex) == index) { if ((words.lastIndex) == index) {
@ -155,15 +153,13 @@ class ZhLayout(
lineStart[line + 1] = index + 1 lineStart[line + 1] = index + 1
lineWidth[line] = lineW - offset lineWidth[line] = lineW - offset
lineW = offset lineW = offset
line++ addLineArray(++line)
addLineArray(line)
} }
/*写满断行、段落末尾、且需要下移字符,这种特殊情况下要额外多一行*/ /*写满断行、段落末尾、且需要下移字符,这种特殊情况下要额外多一行*/
else if (breakCharCnt > 0) { else if (breakCharCnt > 0) {
lineStart[line + 1] = lineStart[line] + breakCharCnt lineStart[line + 1] = lineStart[line] + breakCharCnt
lineWidth[line] = lineW lineWidth[line] = lineW
line++ addLineArray(++line)
addLineArray(line)
} }
} }
cwPre = cw cwPre = cw

Loading…
Cancel
Save