mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
Merge branch 'gedoor:master' into master
This commit is contained in:
commit
4bb0d22cd8
@ -79,8 +79,8 @@ data class TextLine(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getColumnReverseAt(index: Int): BaseColumn {
|
fun getColumnReverseAt(index: Int, offset: Int = 0): BaseColumn {
|
||||||
return textColumns[textColumns.lastIndex - index]
|
return textColumns[textColumns.lastIndex - offset - index]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getColumnsCount(): Int {
|
fun getColumnsCount(): Int {
|
||||||
|
@ -622,7 +622,7 @@ class TextChapterLayout(
|
|||||||
val spaceSize = words.count { it == " " }
|
val spaceSize = words.count { it == " " }
|
||||||
textLine.startX = absStartX + startX
|
textLine.startX = absStartX + startX
|
||||||
if (spaceSize > 1) {
|
if (spaceSize > 1) {
|
||||||
val d = residualWidth / (spaceSize - 1)
|
val d = residualWidth / spaceSize
|
||||||
textLine.wordSpacing = d
|
textLine.wordSpacing = d
|
||||||
var x = startX
|
var x = startX
|
||||||
for (index in words.indices) {
|
for (index in words.indices) {
|
||||||
@ -735,14 +735,25 @@ class TextChapterLayout(
|
|||||||
* 超出边界处理
|
* 超出边界处理
|
||||||
*/
|
*/
|
||||||
private fun exceed(absStartX: Int, textLine: TextLine, words: List<String>) {
|
private fun exceed(absStartX: Int, textLine: TextLine, words: List<String>) {
|
||||||
|
var size = words.size
|
||||||
|
if (size < 2) return
|
||||||
val visibleEnd = absStartX + visibleWidth
|
val visibleEnd = absStartX + visibleWidth
|
||||||
val endX = textLine.columns.lastOrNull()?.end?.roundToInt() ?: return
|
val columns = textLine.columns
|
||||||
|
var offset = 0
|
||||||
|
val endColumn = if (words.last() == " ") {
|
||||||
|
size--
|
||||||
|
offset++
|
||||||
|
columns[columns.lastIndex - 1]
|
||||||
|
} else {
|
||||||
|
columns.last()
|
||||||
|
}
|
||||||
|
val endX = endColumn.end.roundToInt()
|
||||||
if (endX > visibleEnd) {
|
if (endX > visibleEnd) {
|
||||||
textLine.exceed = true
|
textLine.exceed = true
|
||||||
val cc = (endX - visibleEnd) / words.size
|
val cc = (endX - visibleEnd) / size
|
||||||
for (i in 0..words.lastIndex) {
|
for (i in 0..<size) {
|
||||||
textLine.getColumnReverseAt(i).let {
|
textLine.getColumnReverseAt(i, offset).let {
|
||||||
val py = cc * (words.size - i)
|
val py = cc * (size - i)
|
||||||
it.start -= py
|
it.start -= py
|
||||||
it.end -= py
|
it.end -= py
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user