feat: 修复关闭两端对齐是朗读高亮不准确的bug

pull/262/head
gedoor 4 years ago
parent e1f182b975
commit 35a825c1d3
  1. 11
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -124,7 +124,7 @@ object ChapterProvider {
val x = if (isTitle && ReadBookConfig.titleMode == 1) val x = if (isTitle && ReadBookConfig.titleMode == 1)
(visibleWidth - layout.getLineWidth(lineIndex)) / 2 (visibleWidth - layout.getLineWidth(lineIndex)) / 2
else 0f else 0f
addCharsToLineLast(textLine, words, textPaint, x) addCharsToLineLast(textLine, words, textPaint, x, true)
} else { } else {
//中间行 //中间行
addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f)
@ -163,7 +163,7 @@ object ChapterProvider {
) { ) {
var x = 0f var x = 0f
if (!ReadBookConfig.textFullJustify) { if (!ReadBookConfig.textFullJustify) {
addCharsToLineLast(textLine, words, textPaint, x) addCharsToLineLast(textLine, words, textPaint, x, false)
return return
} }
val bodyIndent = ReadBookConfig.bodyIndent val bodyIndent = ReadBookConfig.bodyIndent
@ -192,7 +192,7 @@ object ChapterProvider {
startX: Float startX: Float
) { ) {
if (!ReadBookConfig.textFullJustify) { if (!ReadBookConfig.textFullJustify) {
addCharsToLineLast(textLine, words, textPaint, startX) addCharsToLineLast(textLine, words, textPaint, startX, false)
return return
} }
val gapCount: Int = words.length - 1 val gapCount: Int = words.length - 1
@ -218,9 +218,10 @@ object ChapterProvider {
textLine: TextLine, textLine: TextLine,
words: String, words: String,
textPaint: TextPaint, textPaint: TextPaint,
startX: Float startX: Float,
isLast: Boolean
) { ) {
textLine.text = "$words\n" textLine.text = if (isLast) "$words\n" else words
var x = startX var x = startX
words.toStringArray().forEach { words.toStringArray().forEach {
val cw = StaticLayout.getDesiredWidth(it, textPaint) val cw = StaticLayout.getDesiredWidth(it, textPaint)

Loading…
Cancel
Save