diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt index 8ef5dec58..2ad80b8a1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/entities/TextLine.kt @@ -2,7 +2,7 @@ package io.legado.app.ui.book.read.page.entities import android.text.TextPaint import io.legado.app.ui.book.read.page.provider.ChapterProvider -import io.legado.app.ui.book.read.page.provider.ChapterProvider.textHeight +import io.legado.app.utils.textHeight @Suppress("unused") data class TextLine( 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 ca16553ab..aabab2cb7 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 @@ -550,6 +550,4 @@ object ChapterProvider { } } - val TextPaint.textHeight: Float - get() = fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading } diff --git a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt index 1716e2dc9..80130b627 100644 --- a/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/image/CoverImageView.kt @@ -16,6 +16,8 @@ import io.legado.app.help.AppConfig import io.legado.app.help.glide.ImageLoader import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefString +import io.legado.app.utils.textHeight +import io.legado.app.utils.toStringArray import splitties.init.appCtx /** @@ -44,7 +46,6 @@ class CoverImageView @JvmOverloads constructor( textPaint.typeface = Typeface.DEFAULT_BOLD textPaint.isAntiAlias = true textPaint.textAlign = Paint.Align.CENTER - textPaint.textSkewX = -0.2f textPaint } private val authorPaint by lazy { @@ -52,7 +53,6 @@ class CoverImageView @JvmOverloads constructor( textPaint.typeface = Typeface.DEFAULT textPaint.isAntiAlias = true textPaint.textAlign = Paint.Align.CENTER - textPaint.textSkewX = -0.1f textPaint } @@ -86,11 +86,8 @@ class CoverImageView @JvmOverloads constructor( } namePaint.textSize = width / 6 namePaint.strokeWidth = namePaint.textSize / 10 - authorPaint.textSize = width / 9 + authorPaint.textSize = width / 8 authorPaint.strokeWidth = authorPaint.textSize / 10 - val fm = namePaint.fontMetrics - nameHeight = height * 0.5f + (fm.bottom - fm.top) * 0.5f - authorHeight = nameHeight + (fm.bottom - fm.top) * 0.6f } override fun onDraw(canvas: Canvas) { @@ -104,21 +101,37 @@ class CoverImageView @JvmOverloads constructor( } private fun drawName(canvas: Canvas) { - name?.let { - namePaint.color = Color.WHITE - namePaint.style = Paint.Style.STROKE - canvas.drawText(it, width / 2, nameHeight, namePaint) - namePaint.color = Color.RED - namePaint.style = Paint.Style.FILL - canvas.drawText(it, width / 2, nameHeight, namePaint) + var startX = width * 0.2f + var startY = height * 0.2f + name?.toStringArray()?.let { name -> + name.forEach { + namePaint.color = Color.WHITE + namePaint.style = Paint.Style.STROKE + canvas.drawText(it, startX, startY, namePaint) + namePaint.color = Color.DKGRAY + namePaint.style = Paint.Style.FILL + canvas.drawText(it, startX, startY, namePaint) + startY += namePaint.textHeight + if (startY > height * 0.9) { + return@let + } + } } - author?.let { - authorPaint.color = Color.WHITE - authorPaint.style = Paint.Style.STROKE - canvas.drawText(it, width / 2, authorHeight, authorPaint) - authorPaint.color = Color.RED - authorPaint.style = Paint.Style.FILL - canvas.drawText(it, width / 2, authorHeight, authorPaint) + startX = width * 0.8f + startY = height * 0.7f + author?.toStringArray()?.let { author -> + author.forEach { + authorPaint.color = Color.WHITE + authorPaint.style = Paint.Style.STROKE + canvas.drawText(it, startX, startY, authorPaint) + authorPaint.color = Color.DKGRAY + authorPaint.style = Paint.Style.FILL + canvas.drawText(it, startX, startY, authorPaint) + startY += authorPaint.textHeight + if (startY > height * 0.95) { + return@let + } + } } } diff --git a/app/src/main/java/io/legado/app/utils/PaintExtensions.kt b/app/src/main/java/io/legado/app/utils/PaintExtensions.kt new file mode 100644 index 000000000..5feccd464 --- /dev/null +++ b/app/src/main/java/io/legado/app/utils/PaintExtensions.kt @@ -0,0 +1,6 @@ +package io.legado.app.utils + +import android.text.TextPaint + +val TextPaint.textHeight: Float + get() = fontMetrics.descent - fontMetrics.ascent + fontMetrics.leading \ No newline at end of file diff --git a/app/src/main/res/drawable/image_cover_default.png b/app/src/main/res/drawable/image_cover_default.png index d1bf99d33..025897101 100644 Binary files a/app/src/main/res/drawable/image_cover_default.png and b/app/src/main/res/drawable/image_cover_default.png differ