mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
9181a41458
commit
0ed31ae56c
@ -132,8 +132,7 @@ object BookContent {
|
||||
//全文替换
|
||||
val replaceRegex = contentRule.replaceRegex
|
||||
if (!replaceRegex.isNullOrEmpty()) {
|
||||
contentStr = contentStr.split(AppPattern.LFRegex)
|
||||
.joinToString("\n") { it.trim { c -> c <= ' ' || c == ' ' } }
|
||||
contentStr = contentStr.split(AppPattern.LFRegex).joinToString("\n") { it.trim() }
|
||||
contentStr = analyzeRule.getString(replaceRegex, contentStr)
|
||||
contentStr = contentStr.split(AppPattern.LFRegex).joinToString("\n") { " $it" }
|
||||
}
|
||||
|
@ -809,11 +809,8 @@ object ChapterProvider {
|
||||
paragraphSpacing = ReadBookConfig.paragraphSpacing
|
||||
titleTopSpacing = ReadBookConfig.titleTopSpacing.dpToPx()
|
||||
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dpToPx()
|
||||
var bodyIndent = ReadBookConfig.paragraphIndent
|
||||
val indentLength = bodyIndent.length
|
||||
// 有些字体的中文空格宽度不对
|
||||
bodyIndent = "一".repeat(indentLength)
|
||||
indentCharWidth = StaticLayout.getDesiredWidth(bodyIndent, contentPaint) / indentLength
|
||||
val bodyIndent = ReadBookConfig.paragraphIndent
|
||||
indentCharWidth = StaticLayout.getDesiredWidth(bodyIndent, contentPaint) / bodyIndent.length
|
||||
titlePaintTextHeight = titlePaint.textHeight
|
||||
contentPaintTextHeight = contentPaint.textHeight
|
||||
titlePaintFontMetrics = titlePaint.fontMetrics
|
||||
|
@ -431,6 +431,7 @@ class TextChapterLayout(
|
||||
|
||||
else -> y
|
||||
}
|
||||
val (strList, widthList) = measureTextSplit(text, textPaint)
|
||||
for (lineIndex in 0 until layout.lineCount) {
|
||||
val textLine = TextLine(isTitle = isTitle)
|
||||
if (durY + textHeight > visibleHeight) {
|
||||
@ -461,12 +462,13 @@ class TextChapterLayout(
|
||||
val lineStart = layout.getLineStart(lineIndex)
|
||||
val lineEnd = layout.getLineEnd(lineIndex)
|
||||
val lineText = text.substring(lineStart, lineEnd)
|
||||
val (words, widths) = measureTextSplit(lineText, textPaint)
|
||||
val words = strList.subList(lineStart, lineEnd)
|
||||
val widths = widthList.subList(lineStart, lineEnd)
|
||||
val desiredWidth = widths.fastSum()
|
||||
textLine.text = lineText
|
||||
when {
|
||||
lineIndex == 0 && layout.lineCount > 1 && !isTitle -> {
|
||||
//第一行 非标题
|
||||
//多行的第一行 非标题
|
||||
addCharsToLineFirst(
|
||||
book, absStartX, textLine, words, textPaint,
|
||||
desiredWidth, widths, srcList
|
||||
@ -474,7 +476,7 @@ class TextChapterLayout(
|
||||
}
|
||||
|
||||
lineIndex == layout.lineCount - 1 -> {
|
||||
//最后一行
|
||||
//最后一行、单行
|
||||
//标题x轴居中
|
||||
val startX = if (
|
||||
isTitle &&
|
||||
|
Loading…
Reference in New Issue
Block a user