|
|
|
@ -124,15 +124,7 @@ object ChapterProvider { |
|
|
|
|
//中间行 |
|
|
|
|
addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) |
|
|
|
|
} |
|
|
|
|
if (durY + textPaint.textHeight < visibleHeight) { |
|
|
|
|
//当前页面新增行 |
|
|
|
|
stringBuilder.append(words) |
|
|
|
|
if (isLastLine) stringBuilder.append("\n") |
|
|
|
|
textLine.upTopBottom(durY, textPaint) |
|
|
|
|
textPages.last().textLines.add(textLine) |
|
|
|
|
durY += textPaint.textHeight * lineSpacingExtra / 10f |
|
|
|
|
textPages.last().height = durY |
|
|
|
|
} else { |
|
|
|
|
if (durY + textPaint.textHeight > visibleHeight) { |
|
|
|
|
//当前页面结束,设置各种值 |
|
|
|
|
textPages.last().text = stringBuilder.toString() |
|
|
|
|
pageLines.add(textPages.last().textLines.size) |
|
|
|
@ -141,14 +133,15 @@ object ChapterProvider { |
|
|
|
|
//新建页面 |
|
|
|
|
textPages.add(TextPage()) |
|
|
|
|
stringBuilder.clear() |
|
|
|
|
durY = 0f |
|
|
|
|
} |
|
|
|
|
stringBuilder.append(words) |
|
|
|
|
if (isLastLine) stringBuilder.append("\n") |
|
|
|
|
textLine.upTopBottom(0f, textPaint) |
|
|
|
|
textPages.last().textLines.add(textLine) |
|
|
|
|
durY = textPaint.textHeight * lineSpacingExtra / 10f |
|
|
|
|
textLine.upTopBottom(durY, textPaint) |
|
|
|
|
durY += textPaint.textHeight * lineSpacingExtra / 10f |
|
|
|
|
textPages.last().height = durY |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
durY += textPaint.textHeight * paragraphSpacing / 10f |
|
|
|
|
return durY |
|
|
|
|
} |
|
|
|
|