From e32cfc03e753994c32d5288653ec544b8f72668e Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:13:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadBookConfig.kt | 1 + .../ui/book/read/config/ReadStyleDialog.kt | 2 ++ .../app/ui/book/read/page/ChapterProvider.kt | 19 ++++++++----------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 3ce2f514f..de43e4185 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -254,6 +254,7 @@ object ReadBookConfig { var lineSpacingExtra: Int = 12,//行间距 var paragraphSpacing: Int = 12,//段距 var titleMode: Int = 0,//标题居中 + var titleLineSpacing: Int = 0, var paddingBottom: Int = 6, var paddingLeft: Int = 16, var paddingRight: Int = 16, diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 930ba61b5..7e7d632ab 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -81,6 +81,8 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { dsb_text_letter_spacing.valueFormat = { ((it - 50) / 100f).toString() } + dsb_line_size.valueFormat = { (it / 10f).toString() } + dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } } private fun initData() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index f4b6ca0d4..cf53a9e3f 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -13,10 +13,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.ui.book.read.page.entities.TextLine import io.legado.app.ui.book.read.page.entities.TextPage -import io.legado.app.utils.dp -import io.legado.app.utils.getPrefString -import io.legado.app.utils.removePref -import io.legado.app.utils.toStringArray +import io.legado.app.utils.* @Suppress("DEPRECATION") @@ -111,14 +108,14 @@ object ChapterProvider { val textLine = TextLine(isTitle = isTitle) if (durY + textPaint.textHeight < visibleHeight) { textPages.last().textLines.add(textLine) - durY += textPaint.textHeight + lineSpacingExtra + durY += textPaint.textHeight * lineSpacingExtra / 10f } else { textPages.last().text = stringBuilder.toString() stringBuilder.clear() pageLines.add(textPages.last().textLines.size) pageLengths.add(textPages.last().text.length) //新建页面 - durY = textPaint.textHeight + lineSpacingExtra + durY = textPaint.textHeight * lineSpacingExtra / 10f textPages.add(TextPage()) textPages.last().textLines.add(textLine) } @@ -144,7 +141,7 @@ object ChapterProvider { addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } } - durY += paragraphSpacing + durY += textPaint.textHeight * paragraphSpacing / 10f return durY } @@ -273,10 +270,10 @@ object ChapterProvider { val bold = if (ReadBookConfig.textBold) Typeface.BOLD else Typeface.NORMAL contentPaint.typeface = Typeface.create(typeface, bold) //间距 - lineSpacingExtra = ReadBookConfig.lineSpacingExtra.dp - paragraphSpacing = ReadBookConfig.paragraphSpacing.dp - titlePaint.textSize = (ReadBookConfig.textSize + 2).dp.toFloat() - contentPaint.textSize = ReadBookConfig.textSize.dp.toFloat() + lineSpacingExtra = ReadBookConfig.lineSpacingExtra + paragraphSpacing = ReadBookConfig.paragraphSpacing + titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() + contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() upSize() }