diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt index 727fbcbf8..197c64990 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt @@ -194,6 +194,7 @@ class TextChapterLayout( titlePaint, titlePaintTextHeight, titlePaintFontMetrics, + book.getImageStyle(), isTitle = true, emptyContent = contents.isEmpty(), isVolumeTitle = bookChapter.isVolume @@ -231,6 +232,7 @@ class TextChapterLayout( contentPaint, contentPaintTextHeight, contentPaintFontMetrics, + book.getImageStyle(), srcList = srcList ).let { absStartX = it.first @@ -250,7 +252,8 @@ class TextChapterLayout( text, contentPaint, contentPaintTextHeight, - contentPaintFontMetrics + contentPaintFontMetrics, + book.getImageStyle() ).let { absStartX = it.first durY = it.second @@ -278,7 +281,8 @@ class TextChapterLayout( if (AppConfig.enableReview) text + ChapterProvider.reviewChar else text, contentPaint, contentPaintTextHeight, - contentPaintFontMetrics + contentPaintFontMetrics, + book.getImageStyle() ).let { absStartX = it.first durY = it.second @@ -443,6 +447,7 @@ class TextChapterLayout( textPaint: TextPaint, textHeight: Float, fontMetrics: Paint.FontMetrics, + imageStyle: String?, isTitle: Boolean = false, emptyContent: Boolean = false, isVolumeTitle: Boolean = false, @@ -487,8 +492,31 @@ class TextChapterLayout( } } - isTitle && textPages.isEmpty() && pendingTextPage.lines.isEmpty() -> - y + titleTopSpacing + isTitle && textPages.isEmpty() && pendingTextPage.lines.isEmpty() -> { + when (imageStyle?.uppercase(Locale.ROOT)) { + Book.imgStyleSingle -> { + val textPage = pendingTextPage + if (textPage.lineSize == 0) { + val ty = (visibleHeight - layout.lineCount * textHeight) / 2 + if (ty > titleTopSpacing) ty else titleTopSpacing.toFloat() + } else { + var textLayoutHeight = layout.lineCount * textHeight + val fistLine = textPage.getLine(0) + if (fistLine.lineTop < textLayoutHeight + titleTopSpacing) { + textLayoutHeight = fistLine.lineTop - titleTopSpacing + } + textPage.lines.forEach { + it.lineTop -= textLayoutHeight + it.lineBase -= textLayoutHeight + it.lineBottom -= textLayoutHeight + } + y - textLayoutHeight + } + } + + else -> y + titleTopSpacing + } + } else -> y } @@ -539,7 +567,7 @@ class TextChapterLayout( //标题x轴居中 val startX = if ( isTitle && - (ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle) + (ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle || imageStyle == "SINGLE") ) { (visibleWidth - desiredWidth) / 2 } else { @@ -554,7 +582,7 @@ class TextChapterLayout( else -> { if ( isTitle && - (ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle) + (ReadBookConfig.isMiddleTitle || emptyContent || isVolumeTitle || imageStyle == "SINGLE") ) { //标题居中 val startX = (visibleWidth - desiredWidth) / 2