优化图片text的效果

pull/889/head
hoodie13 4 years ago
parent 6ba115ebd6
commit 0586dd17aa
  1. 5
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 3
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -165,9 +165,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
lineBottom: Float, lineBottom: Float,
) { ) {
ReadBook.book?.let { book -> ReadBook.book?.let { book ->
val rectF = RectF(textChar.start, lineTop, textChar.end, lineBottom)
ImageProvider.getImage(book, textPage.chapterIndex, textChar.charData, true) ImageProvider.getImage(book, textPage.chapterIndex, textChar.charData, true)
?.let { ?.let {
/*以宽度为基准保持图片的原始比例叠加,当div为负数时,允许高度比字符更高*/
val h = (textChar.end - textChar.start) / it.width * it.height
val div = (lineBottom - lineTop - h) / 2
val rectF = RectF(textChar.start, lineTop + div, textChar.end, lineBottom - div)
canvas.drawBitmap(it, null, rectF, null) canvas.drawBitmap(it, null, rectF, null)
} }
} }

@ -69,7 +69,8 @@ object ChapterProvider {
@JvmStatic @JvmStatic
lateinit var contentPaint: TextPaint lateinit var contentPaint: TextPaint
private const val srcReplaceChar = "🖼" /*🖼字符长度是2,做自定义排版等一些处理时会异常,用卍取代*/
private const val srcReplaceChar = ""
init { init {
upStyle() upStyle()

Loading…
Cancel
Save