|
|
@ -28,6 +28,8 @@ object ChapterProvider { |
|
|
|
var visibleBottom = 0 |
|
|
|
var visibleBottom = 0 |
|
|
|
private var lineSpacingExtra = 0 |
|
|
|
private var lineSpacingExtra = 0 |
|
|
|
private var paragraphSpacing = 0 |
|
|
|
private var paragraphSpacing = 0 |
|
|
|
|
|
|
|
private var titleTopSpacing = 0 |
|
|
|
|
|
|
|
private var titleBottomSpacing = 0 |
|
|
|
var typeface: Typeface = Typeface.SANS_SERIF |
|
|
|
var typeface: Typeface = Typeface.SANS_SERIF |
|
|
|
var titlePaint = TextPaint() |
|
|
|
var titlePaint = TextPaint() |
|
|
|
var contentPaint = TextPaint() |
|
|
|
var contentPaint = TextPaint() |
|
|
@ -97,7 +99,7 @@ object ChapterProvider { |
|
|
|
stringBuilder: StringBuilder, |
|
|
|
stringBuilder: StringBuilder, |
|
|
|
isTitle: Boolean |
|
|
|
isTitle: Boolean |
|
|
|
): Float { |
|
|
|
): Float { |
|
|
|
var durY = y |
|
|
|
var durY = if (isTitle) y + titleTopSpacing else y |
|
|
|
val textPaint = if (isTitle) titlePaint else contentPaint |
|
|
|
val textPaint = if (isTitle) titlePaint else contentPaint |
|
|
|
val layout = StaticLayout( |
|
|
|
val layout = StaticLayout( |
|
|
|
text, textPaint, visibleWidth, |
|
|
|
text, textPaint, visibleWidth, |
|
|
@ -140,6 +142,9 @@ object ChapterProvider { |
|
|
|
textPages.last().textLines.add(textLine) |
|
|
|
textPages.last().textLines.add(textLine) |
|
|
|
textLine.upTopBottom(durY, textPaint) |
|
|
|
textLine.upTopBottom(durY, textPaint) |
|
|
|
durY += textPaint.textHeight * lineSpacingExtra / 10f |
|
|
|
durY += textPaint.textHeight * lineSpacingExtra / 10f |
|
|
|
|
|
|
|
if (isTitle) { |
|
|
|
|
|
|
|
durY += titleBottomSpacing |
|
|
|
|
|
|
|
} |
|
|
|
textPages.last().height = durY |
|
|
|
textPages.last().height = durY |
|
|
|
} |
|
|
|
} |
|
|
|
durY += textPaint.textHeight * paragraphSpacing / 10f |
|
|
|
durY += textPaint.textHeight * paragraphSpacing / 10f |
|
|
@ -273,7 +278,8 @@ object ChapterProvider { |
|
|
|
paragraphSpacing = ReadBookConfig.paragraphSpacing |
|
|
|
paragraphSpacing = ReadBookConfig.paragraphSpacing |
|
|
|
titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() |
|
|
|
titlePaint.textSize = (ReadBookConfig.textSize + 2).sp.toFloat() |
|
|
|
contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() |
|
|
|
contentPaint.textSize = ReadBookConfig.textSize.sp.toFloat() |
|
|
|
|
|
|
|
titleTopSpacing = ReadBookConfig.titleTopSpacing.dp |
|
|
|
|
|
|
|
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp |
|
|
|
upSize() |
|
|
|
upSize() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|