mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
Update Cronet / build (push) Has been cancelled
Some checks failed
Test Build / prepare (push) Has been cancelled
Test Build / build (app, release) (push) Has been cancelled
Test Build / build (app, releaseA) (push) Has been cancelled
Test Build / prerelease (push) Has been cancelled
Test Build / lanzou (push) Has been cancelled
Test Build / test_Branch (push) Has been cancelled
Test Build / telegram (push) Has been cancelled
Update Cronet / build (push) Has been cancelled
This commit is contained in:
@@ -803,19 +803,10 @@ class TextChapterLayout(
|
||||
var i = 0
|
||||
while (i < length) {
|
||||
val clusterBaseIndex = i++
|
||||
var extra = 0f
|
||||
while (i < length) {
|
||||
val c = text[i]
|
||||
val w = widthsArray[start + i]
|
||||
if (w > 0 || isZeroWidthChar(c)) {
|
||||
if (!c.isLowSurrogate()) {
|
||||
break
|
||||
}
|
||||
extra = w
|
||||
}
|
||||
widths.add(widthsArray[start + clusterBaseIndex])
|
||||
while (i < length && widthsArray[start + i] == 0f && !isZeroWidthChar(text[i])) {
|
||||
i++
|
||||
}
|
||||
widths.add(widthsArray[start + clusterBaseIndex] + extra)
|
||||
stringList.add(text.substring(clusterBaseIndex, i))
|
||||
}
|
||||
return stringList to widths
|
||||
|
||||
@@ -11,7 +11,17 @@ fun TextPaint.getTextWidthsCompat(text: String, widths: FloatArray) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
val letterSpacing = letterSpacing * textSize
|
||||
val letterSpacingHalf = letterSpacing * 0.5f
|
||||
widths[0] += letterSpacingHalf
|
||||
widths[text.lastIndex] += letterSpacingHalf
|
||||
for (i in widths.indices) {
|
||||
if (widths[i] > 0) {
|
||||
widths[i] += letterSpacingHalf
|
||||
break
|
||||
}
|
||||
}
|
||||
for (i in text.lastIndex downTo 0) {
|
||||
if (widths[i] > 0) {
|
||||
widths[i] += letterSpacingHalf
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user