From 0586dd17aa021c0973625d5ea7ced8a6b4363b50 Mon Sep 17 00:00:00 2001 From: hoodie13 <74173949+hoodie13@users.noreply.github.com> Date: Sat, 13 Mar 2021 01:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87text?= =?UTF-8?q?=E7=9A=84=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ContentTextView.kt | 5 ++++- .../legado/app/ui/book/read/page/provider/ChapterProvider.kt | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 3fba231a4..9c696b89d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -165,9 +165,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at lineBottom: Float, ) { ReadBook.book?.let { book -> - val rectF = RectF(textChar.start, lineTop, textChar.end, lineBottom) ImageProvider.getImage(book, textPage.chapterIndex, textChar.charData, true) ?.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) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index 54fec4b6e..786050eab 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -69,7 +69,8 @@ object ChapterProvider { @JvmStatic lateinit var contentPaint: TextPaint - private const val srcReplaceChar = "🖼" + /*🖼字符长度是2,做自定义排版等一些处理时会异常,用卍取代*/ + private const val srcReplaceChar = "卍" init { upStyle()