This commit is contained in:
Horis 2024-03-31 11:38:44 +08:00
parent 2b90015125
commit ad7f3f30fc

View File

@ -218,10 +218,8 @@ data class TextLine(
if (exceed || !onlyTextColumn || textPage.isMsgPage) { if (exceed || !onlyTextColumn || textPage.isMsgPage) {
return false return false
} }
if (wordSpacing != 0f) { if (wordSpacing != 0f && (!atLeastApi26 || !wordSpacingWorking)) {
if (!atLeastApi26 || !wordSpacingWorking) { return false
return false
}
} }
return searchResultColumnCount == 0 return searchResultColumnCount == 0
} }
@ -244,14 +242,19 @@ data class TextLine(
val emptyTextLine = TextLine() val emptyTextLine = TextLine()
private val atLeastApi26 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O private val atLeastApi26 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
private val wordSpacingWorking by lazy { private val wordSpacingWorking by lazy {
// issue 3785 // issue 3785 3846
val paint = PaintPool.obtain() val paint = PaintPool.obtain()
val text = "一二 三" val text = "一二 三"
val width1 = paint.measureText(text) val width1 = paint.measureText(text)
paint.wordSpacing = 10f try {
val width2 = paint.measureText(text) paint.wordSpacing = 10f
PaintPool.recycle(paint) val width2 = paint.measureText(text)
width2 - width1 == 10f width2 - width1 == 10f
} catch (e: NoSuchMethodError) {
false
} finally {
PaintPool.recycle(paint)
}
} }
} }