Horis hace 2 años
padre
commit
7be5eae014

+ 5 - 2
app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@@ -782,8 +782,11 @@ object ChapterProvider {
         paragraphSpacing = ReadBookConfig.paragraphSpacing
         titleTopSpacing = ReadBookConfig.titleTopSpacing.dpToPx()
         titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dpToPx()
-        val bodyIndent = ReadBookConfig.paragraphIndent
-        indentCharWidth = StaticLayout.getDesiredWidth(bodyIndent, contentPaint) / bodyIndent.length
+        var bodyIndent = ReadBookConfig.paragraphIndent
+        val indentLength = bodyIndent.length
+        // 有些字体的中文空格宽度不对
+        bodyIndent = "一".repeat(indentLength)
+        indentCharWidth = StaticLayout.getDesiredWidth(bodyIndent, contentPaint) / indentLength
         titlePaintTextHeight = titlePaint.textHeight
         contentPaintTextHeight = contentPaint.textHeight
         titlePaintFontMetrics = titlePaint.fontMetrics