This commit is contained in:
Horis
2025-02-21 11:35:09 +08:00
parent 632d03fb63
commit 847abe37f4
@@ -242,7 +242,7 @@ class TextChapterLayout(
contentPaint, contentPaint,
contentPaintTextHeight, contentPaintTextHeight,
contentPaintFontMetrics, contentPaintFontMetrics,
book.getImageStyle(), imageStyle,
srcList = srcList srcList = srcList
) )
} else { } else {
@@ -250,8 +250,9 @@ class TextChapterLayout(
isSetTypedImage = false isSetTypedImage = false
prepareNextPageIfNeed() prepareNextPageIfNeed()
} }
val matcher = AppPattern.imgPattern.matcher(content)
var start = 0 var start = 0
if (content.contains("<img")) {
val matcher = AppPattern.imgPattern.matcher(content)
while (matcher.find()) { while (matcher.find()) {
coroutineContext.ensureActive() coroutineContext.ensureActive()
val text = content.substring(start, matcher.start()) val text = content.substring(start, matcher.start())
@@ -262,7 +263,7 @@ class TextChapterLayout(
contentPaint, contentPaint,
contentPaintTextHeight, contentPaintTextHeight,
contentPaintFontMetrics, contentPaintFontMetrics,
book.getImageStyle(), imageStyle,
isFirstLine = start == 0 isFirstLine = start == 0
) )
} }
@@ -270,11 +271,12 @@ class TextChapterLayout(
book, book,
matcher.group(1)!!, matcher.group(1)!!,
contentPaintTextHeight, contentPaintTextHeight,
book.getImageStyle() imageStyle
) )
isSetTypedImage = true isSetTypedImage = true
start = matcher.end() start = matcher.end()
} }
}
if (start < content.length) { if (start < content.length) {
if (isSingleImageStyle && isSetTypedImage) { if (isSingleImageStyle && isSetTypedImage) {
isSetTypedImage = false isSetTypedImage = false
@@ -288,7 +290,7 @@ class TextChapterLayout(
contentPaint, contentPaint,
contentPaintTextHeight, contentPaintTextHeight,
contentPaintFontMetrics, contentPaintFontMetrics,
book.getImageStyle(), imageStyle,
isFirstLine = start == 0 isFirstLine = start == 0
) )
} }