This commit is contained in:
Horis 2023-05-20 17:52:31 +08:00
parent d9d5469454
commit 435db730f0

View File

@ -182,7 +182,7 @@ object ChapterProvider {
} }
durY = setTypeImage( durY = setTypeImage(
book, matcher.group(1)!!, book, matcher.group(1)!!,
absStartX, durY, textPages, book.getImageStyle() absStartX, durY, textPages, stringBuilder, book.getImageStyle()
) )
start = matcher.end() start = matcher.end()
} }
@ -232,13 +232,17 @@ object ChapterProvider {
x: Int, x: Int,
y: Float, y: Float,
textPages: ArrayList<TextPage>, textPages: ArrayList<TextPage>,
stringBuilder: StringBuilder,
imageStyle: String?, imageStyle: String?,
): Float { ): Float {
var durY = y var durY = y
val size = ImageProvider.getImageSize(book, src, ReadBook.bookSource) val size = ImageProvider.getImageSize(book, src, ReadBook.bookSource)
if (size.width > 0 && size.height > 0) { if (size.width > 0 && size.height > 0) {
if (durY > visibleHeight) { if (durY > visibleHeight) {
textPages.last().height = durY val textPage = textPages.last()
textPage.height = durY
textPage.text = stringBuilder.toString()
stringBuilder.clear()
textPages.add(TextPage()) textPages.add(TextPage())
durY = 0f durY = 0f
} }
@ -249,6 +253,7 @@ object ChapterProvider {
width = visibleWidth width = visibleWidth
height = size.height * visibleWidth / size.width height = size.height * visibleWidth / size.width
} }
else -> { else -> {
if (size.width > visibleWidth) { if (size.width > visibleWidth) {
height = size.height * visibleWidth / size.width height = size.height * visibleWidth / size.width
@ -259,7 +264,10 @@ object ChapterProvider {
height = visibleHeight height = visibleHeight
} }
if (durY + height > visibleHeight) { if (durY + height > visibleHeight) {
textPages.last().height = durY val textPage = textPages.last()
textPage.height = durY
textPage.text = stringBuilder.toString()
stringBuilder.clear()
textPages.add(TextPage()) textPages.add(TextPage())
durY = 0f durY = 0f
} }
@ -326,8 +334,10 @@ object ChapterProvider {
y - textLayoutHeight y - textLayoutHeight
} }
} }
isTitle && textPages.size == 1 && textPages.last().lines.isEmpty() -> isTitle && textPages.size == 1 && textPages.last().lines.isEmpty() ->
y + titleTopSpacing y + titleTopSpacing
else -> y else -> y
} }
for (lineIndex in 0 until layout.lineCount) { for (lineIndex in 0 until layout.lineCount) {
@ -363,6 +373,7 @@ object ChapterProvider {
textPaint, desiredWidth, srcList textPaint, desiredWidth, srcList
) )
} }
lineIndex == layout.lineCount - 1 -> { lineIndex == layout.lineCount - 1 -> {
//最后一行 //最后一行
textLine.text = words textLine.text = words
@ -381,6 +392,7 @@ object ChapterProvider {
startX, !isTitle && lineIndex == 0, srcList startX, !isTitle && lineIndex == 0, srcList
) )
} }
else -> { else -> {
if ( if (
isTitle && isTitle &&
@ -566,6 +578,7 @@ object ChapterProvider {
src = src src = src
) )
} }
isLineEnd && char == reviewChar -> { isLineEnd && char == reviewChar -> {
ReviewColumn( ReviewColumn(
start = absStartX + xStart, start = absStartX + xStart,
@ -573,6 +586,7 @@ object ChapterProvider {
count = 100 count = 100
) )
} }
else -> { else -> {
TextColumn( TextColumn(
start = absStartX + xStart, start = absStartX + xStart,
@ -632,9 +646,11 @@ object ChapterProvider {
Typeface.Builder(it.fileDescriptor).build() Typeface.Builder(it.fileDescriptor).build()
} }
} }
fontPath.isContentScheme() -> { fontPath.isContentScheme() -> {
Typeface.createFromFile(RealPathUtil.getPath(appCtx, Uri.parse(fontPath))) Typeface.createFromFile(RealPathUtil.getPath(appCtx, Uri.parse(fontPath)))
} }
fontPath.isNotEmpty() -> Typeface.createFromFile(fontPath) fontPath.isNotEmpty() -> Typeface.createFromFile(fontPath)
else -> when (AppConfig.systemTypefaces) { else -> when (AppConfig.systemTypefaces) {
1 -> Typeface.SERIF 1 -> Typeface.SERIF
@ -660,12 +676,14 @@ object ChapterProvider {
else else
Pair(bold, bold) Pair(bold, bold)
} }
2 -> { 2 -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
Pair(normal, Typeface.create(typeface, 300, false)) Pair(normal, Typeface.create(typeface, 300, false))
else else
Pair(normal, normal) Pair(normal, normal)
} }
else -> Pair(bold, normal) else -> Pair(bold, normal)
} }
@ -709,6 +727,7 @@ object ChapterProvider {
doublePage = (viewWidth > viewHeight) doublePage = (viewWidth > viewHeight)
&& ReadBook.pageAnim() != 3 && ReadBook.pageAnim() != 3
} }
"3" -> { "3" -> {
doublePage = (viewWidth > viewHeight || appCtx.isPad) doublePage = (viewWidth > viewHeight || appCtx.isPad)
&& ReadBook.pageAnim() != 3 && ReadBook.pageAnim() != 3