|
|
@@ -72,6 +72,8 @@ class TextChapterLayout(
|
|
|
private val indentCharWidth = ChapterProvider.indentCharWidth
|
|
|
private val stringBuilder = StringBuilder()
|
|
|
|
|
|
+ private val paragraphIndent = ReadBookConfig.paragraphIndent
|
|
|
+
|
|
|
private var pendingTextPage = TextPage()
|
|
|
|
|
|
private var isCompleted = false
|
|
|
@@ -252,7 +254,8 @@ class TextChapterLayout(
|
|
|
contentPaint,
|
|
|
contentPaintTextHeight,
|
|
|
contentPaintFontMetrics,
|
|
|
- book.getImageStyle()
|
|
|
+ book.getImageStyle(),
|
|
|
+ isFirstLine = start == 0
|
|
|
).let {
|
|
|
absStartX = it.first
|
|
|
durY = it.second
|
|
|
@@ -281,7 +284,8 @@ class TextChapterLayout(
|
|
|
contentPaint,
|
|
|
contentPaintTextHeight,
|
|
|
contentPaintFontMetrics,
|
|
|
- book.getImageStyle()
|
|
|
+ book.getImageStyle(),
|
|
|
+ isFirstLine = start == 0
|
|
|
).let {
|
|
|
absStartX = it.first
|
|
|
durY = it.second
|
|
|
@@ -442,6 +446,7 @@ class TextChapterLayout(
|
|
|
fontMetrics: Paint.FontMetrics,
|
|
|
imageStyle: String?,
|
|
|
isTitle: Boolean = false,
|
|
|
+ isFirstLine: Boolean = true,
|
|
|
emptyContent: Boolean = false,
|
|
|
isVolumeTitle: Boolean = false,
|
|
|
srcList: LinkedList<String>? = null
|
|
|
@@ -459,7 +464,8 @@ class TextChapterLayout(
|
|
|
}
|
|
|
val layout = if (ReadBookConfig.useZhLayout) {
|
|
|
val (words, widths) = measureTextSplit(text, widthsArray)
|
|
|
- ZhLayout(text, textPaint, visibleWidth, words, widths)
|
|
|
+ val indentSize = if (isFirstLine) paragraphIndent.length else 0
|
|
|
+ ZhLayout(text, textPaint, visibleWidth, words, widths, indentSize)
|
|
|
} else {
|
|
|
StaticLayout(text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true)
|
|
|
}
|
|
|
@@ -532,7 +538,7 @@ class TextChapterLayout(
|
|
|
val desiredWidth = widths.fastSum()
|
|
|
textLine.text = lineText
|
|
|
when {
|
|
|
- lineIndex == 0 && layout.lineCount > 1 && !isTitle -> {
|
|
|
+ lineIndex == 0 && layout.lineCount > 1 && !isTitle && isFirstLine -> {
|
|
|
//多行的第一行 非标题
|
|
|
addCharsToLineFirst(
|
|
|
book, absStartX, textLine, words, textPaint,
|
|
|
@@ -638,8 +644,8 @@ class TextChapterLayout(
|
|
|
)
|
|
|
return
|
|
|
}
|
|
|
- val bodyIndent = ReadBookConfig.paragraphIndent
|
|
|
- for (i in bodyIndent.indices) {
|
|
|
+ val bodyIndent = paragraphIndent
|
|
|
+ repeat(bodyIndent.length) {
|
|
|
val x1 = x + indentCharWidth
|
|
|
textLine.addColumn(
|
|
|
TextColumn(
|
|
|
@@ -708,7 +714,7 @@ class TextChapterLayout(
|
|
|
}
|
|
|
} else {
|
|
|
val gapCount: Int = words.lastIndex
|
|
|
- val d = residualWidth / gapCount
|
|
|
+ val d = if (gapCount > 0) residualWidth / gapCount else 0f
|
|
|
textLine.extraLetterSpacingOffsetX = -d / 2
|
|
|
textLine.extraLetterSpacing = d / textPaint.textSize
|
|
|
var x = startX
|