| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -20,6 +20,7 @@ import io.legado.app.utils.getPrefString | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.removePref | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.removePref | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					@Suppress("DEPRECATION") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					object ChapterProvider { | 
					 | 
					 | 
					 | 
					object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    var viewWidth = 0 | 
					 | 
					 | 
					 | 
					    var viewWidth = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    var viewHeight = 0 | 
					 | 
					 | 
					 | 
					    var viewHeight = 0 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -31,6 +32,7 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private var paragraphSpacing = 0 | 
					 | 
					 | 
					 | 
					    private var paragraphSpacing = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    var titlePaint = TextPaint() | 
					 | 
					 | 
					 | 
					    var titlePaint = TextPaint() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    var contentPaint = TextPaint() | 
					 | 
					 | 
					 | 
					    var contentPaint = TextPaint() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    private var bodyIndent = BookHelp.bodyIndent | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    init { | 
					 | 
					 | 
					 | 
					    init { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        upStyle(ReadBookConfig.durConfig) | 
					 | 
					 | 
					 | 
					        upStyle(ReadBookConfig.durConfig) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -64,6 +66,9 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        paragraphSpacing = config.paragraphSpacing.dp | 
					 | 
					 | 
					 | 
					        paragraphSpacing = config.paragraphSpacing.dp | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        titlePaint.textSize = (config.textSize + 2).dp.toFloat() | 
					 | 
					 | 
					 | 
					        titlePaint.textSize = (config.textSize + 2).dp.toFloat() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        contentPaint.textSize = config.textSize.dp.toFloat() | 
					 | 
					 | 
					 | 
					        contentPaint.textSize = config.textSize.dp.toFloat() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        bodyIndent = BookHelp.bodyIndent | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        upSize(config) | 
					 | 
					 | 
					 | 
					        upSize(config) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -74,14 +79,12 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        visibleHeight = viewHeight - paddingTop - config.paddingBottom.dp | 
					 | 
					 | 
					 | 
					        visibleHeight = viewHeight - paddingTop - config.paddingBottom.dp | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    @Suppress("DEPRECATION") | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fun getTextChapter( | 
					 | 
					 | 
					 | 
					    fun getTextChapter( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        bookChapter: BookChapter, | 
					 | 
					 | 
					 | 
					        bookChapter: BookChapter, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        content: String, | 
					 | 
					 | 
					 | 
					        content: String, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        chapterSize: Int, | 
					 | 
					 | 
					 | 
					        chapterSize: Int, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        isHtml: Boolean = false | 
					 | 
					 | 
					 | 
					        isHtml: Boolean = false | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ): TextChapter { | 
					 | 
					 | 
					 | 
					    ): TextChapter { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val bodyIndent = BookHelp.bodyIndent | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val textPages = arrayListOf<TextPage>() | 
					 | 
					 | 
					 | 
					        val textPages = arrayListOf<TextPage>() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val pageLines = arrayListOf<Int>() | 
					 | 
					 | 
					 | 
					        val pageLines = arrayListOf<Int>() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val pageLengths = arrayListOf<Int>() | 
					 | 
					 | 
					 | 
					        val pageLengths = arrayListOf<Int>() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -95,9 +98,45 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (end > 0) { | 
					 | 
					 | 
					 | 
					                if (end > 0) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val title = surplusText.substring(0, end) | 
					 | 
					 | 
					 | 
					                    val title = surplusText.substring(0, end) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    surplusText = surplusText.substring(end + 1) | 
					 | 
					 | 
					 | 
					                    surplusText = surplusText.substring(end + 1) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    durY = joinTitle(title, durY, textPages) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                //正文 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                val end = surplusText.indexOf("\n") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                val text: String | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (end >= 0) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    text = surplusText.substring(0, end) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    surplusText = surplusText.substring(end + 1) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    text = surplusText | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    surplusText = "" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                durY = joinBody(text, durY, textPages) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        for ((index, item) in textPages.withIndex()) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            item.index = index | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            item.pageSize = textPages.size | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            item.chapterIndex = bookChapter.index | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            item.chapterSize = chapterSize | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            item.title = bookChapter.title | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return TextChapter( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            bookChapter.index, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            bookChapter.title, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            bookChapter.url, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            textPages, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            pageLines, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            pageLengths, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            chapterSize | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    private fun joinTitle(title: String, y: Int, textPages: ArrayList<TextPage>): Int { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        var durY = y | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val layout = StaticLayout( | 
					 | 
					 | 
					 | 
					        val layout = StaticLayout( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            title, titlePaint, visibleWidth, | 
					 | 
					 | 
					 | 
					            title, titlePaint, visibleWidth, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        Layout.Alignment.ALIGN_NORMAL, 1f, lineSpacingExtra, false | 
					 | 
					 | 
					 | 
					            Layout.Alignment.ALIGN_NORMAL, 1f, lineSpacingExtra, true | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ) | 
					 | 
					 | 
					 | 
					        ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for (lineIndex in 0 until layout.lineCount) { | 
					 | 
					 | 
					 | 
					        for (lineIndex in 0 until layout.lineCount) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            durY = durY + layout.getLineBottom(lineIndex) - layout.getLineTop(lineIndex) | 
					 | 
					 | 
					 | 
					            durY = durY + layout.getLineBottom(lineIndex) - layout.getLineTop(lineIndex) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -109,8 +148,12 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                textPages.add(TextPage()) | 
					 | 
					 | 
					 | 
					                textPages.add(TextPage()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                textPages.last().textLines.add(textLine) | 
					 | 
					 | 
					 | 
					                textPages.last().textLines.add(textLine) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        textLine.lineBottom = layout.getLineBottom(lineIndex) | 
					 | 
					 | 
					 | 
					            textLine.lineBottom = | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        textLine.lineTop = layout.getLineTop(lineIndex) | 
					 | 
					 | 
					 | 
					                paddingTop + durY - layout.getLineBottom(lineIndex) + layout.getLineBaseline( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    lineIndex | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            textLine.lineTop = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                paddingTop + durY - layout.getLineBottom(lineIndex) + layout.getLineTop(lineIndex) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            val words = title.substring( | 
					 | 
					 | 
					 | 
					            val words = title.substring( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                layout.getLineStart(lineIndex), | 
					 | 
					 | 
					 | 
					                layout.getLineStart(lineIndex), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                layout.getLineEnd(lineIndex) | 
					 | 
					 | 
					 | 
					                layout.getLineEnd(lineIndex) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -130,11 +173,8 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        charData = char, | 
					 | 
					 | 
					 | 
					                        charData = char, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    leftBottomPosition = Point(paddingLeft + x, paddingTop + durY), | 
					 | 
					 | 
					 | 
					                        leftBottomPosition = Point(paddingLeft + x, textLine.lineBottom), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    rightTopPosition = Point( | 
					 | 
					 | 
					 | 
					                        rightTopPosition = Point(paddingLeft + x1, textLine.lineTop) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                        paddingLeft + x1, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                        paddingTop + durY - (textLine.lineBottom - textLine.lineTop) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    ) | 
					 | 
					 | 
					 | 
					                    ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    x = x1 | 
					 | 
					 | 
					 | 
					                    x = x1 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -148,11 +188,8 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val x1 = (x + cw).toInt() | 
					 | 
					 | 
					 | 
					                    val x1 = (x + cw).toInt() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        charData = char, | 
					 | 
					 | 
					 | 
					                        charData = char, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    leftBottomPosition = Point(paddingLeft + x, paddingTop + durY), | 
					 | 
					 | 
					 | 
					                        leftBottomPosition = Point(paddingLeft + x, textLine.lineBottom), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    rightTopPosition = Point( | 
					 | 
					 | 
					 | 
					                        rightTopPosition = Point(paddingLeft + x1, textLine.lineTop) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                        paddingLeft + x1, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                        paddingTop + durY - (textLine.lineBottom - textLine.lineTop) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    ) | 
					 | 
					 | 
					 | 
					                    ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    x = x1 | 
					 | 
					 | 
					 | 
					                    x = x1 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -160,21 +197,14 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        durY += paragraphSpacing | 
					 | 
					 | 
					 | 
					        durY += paragraphSpacing | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return durY | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else { | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                //正文 | 
					 | 
					 | 
					 | 
					    private fun joinBody(text: String, y: Int, textPages: ArrayList<TextPage>): Int { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                val end = surplusText.indexOf("\n") | 
					 | 
					 | 
					 | 
					        var durY = y | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                val text: String | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (end >= 0) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    text = surplusText.substring(0, end) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    surplusText = surplusText.substring(end + 1) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } else { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    text = surplusText | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    surplusText = "" | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val layout = StaticLayout( | 
					 | 
					 | 
					 | 
					        val layout = StaticLayout( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            text, contentPaint, visibleWidth, | 
					 | 
					 | 
					 | 
					            text, contentPaint, visibleWidth, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    Layout.Alignment.ALIGN_NORMAL, 1f, lineSpacingExtra, false | 
					 | 
					 | 
					 | 
					            Layout.Alignment.ALIGN_NORMAL, 1f, lineSpacingExtra, true | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ) | 
					 | 
					 | 
					 | 
					        ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for (lineIndex in 0 until layout.lineCount) { | 
					 | 
					 | 
					 | 
					        for (lineIndex in 0 until layout.lineCount) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            val textLine = TextLine(isTitle = false) | 
					 | 
					 | 
					 | 
					            val textLine = TextLine(isTitle = false) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -186,8 +216,14 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                textPages.add(TextPage()) | 
					 | 
					 | 
					 | 
					                textPages.add(TextPage()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                textPages.last().textLines.add(textLine) | 
					 | 
					 | 
					 | 
					                textPages.last().textLines.add(textLine) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.lineBottom = layout.getLineBottom(lineIndex) | 
					 | 
					 | 
					 | 
					            textLine.lineBottom = | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.lineTop = layout.getLineTop(lineIndex) | 
					 | 
					 | 
					 | 
					                paddingTop + durY - layout.getLineBottom(lineIndex) + layout.getLineBaseline( | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    lineIndex | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            textLine.lineTop = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                paddingTop + durY - layout.getLineBottom(lineIndex) + layout.getLineTop( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    lineIndex | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            var words = | 
					 | 
					 | 
					 | 
					            var words = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) | 
					 | 
					 | 
					 | 
					                text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            val desiredWidth = layout.getLineMax(lineIndex) | 
					 | 
					 | 
					 | 
					            val desiredWidth = layout.getLineMax(lineIndex) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -198,11 +234,8 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                var x1 = (x + icw).toInt() | 
					 | 
					 | 
					 | 
					                var x1 = (x + icw).toInt() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                val textChar = TextChar( | 
					 | 
					 | 
					 | 
					                val textChar = TextChar( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    charData = bodyIndent, | 
					 | 
					 | 
					 | 
					                    charData = bodyIndent, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            leftBottomPosition = Point(paddingLeft + x, paddingTop + durY), | 
					 | 
					 | 
					 | 
					                    leftBottomPosition = Point(paddingLeft + x, textLine.lineBottom), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            rightTopPosition = Point( | 
					 | 
					 | 
					 | 
					                    rightTopPosition = Point(paddingLeft + x1, textLine.lineTop) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                paddingLeft + x1, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                paddingTop + durY - (textLine.lineBottom - textLine.lineTop) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                ) | 
					 | 
					 | 
					 | 
					                ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                textLine.textChars.add(textChar) | 
					 | 
					 | 
					 | 
					                textLine.textChars.add(textChar) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                x = x1 | 
					 | 
					 | 
					 | 
					                x = x1 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -219,11 +252,8 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val textChar1 = TextChar( | 
					 | 
					 | 
					 | 
					                    val textChar1 = TextChar( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        charData = char, | 
					 | 
					 | 
					 | 
					                        charData = char, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                leftBottomPosition = Point(paddingLeft + x, paddingTop + durY), | 
					 | 
					 | 
					 | 
					                        leftBottomPosition = Point(paddingLeft + x, textLine.lineBottom), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                rightTopPosition = Point( | 
					 | 
					 | 
					 | 
					                        rightTopPosition = Point(paddingLeft + x1, textLine.lineTop) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    paddingLeft + x1, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    paddingTop + durY - (textLine.lineBottom - textLine.lineTop) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    ) | 
					 | 
					 | 
					 | 
					                    ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar1) | 
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar1) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    x = x1 | 
					 | 
					 | 
					 | 
					                    x = x1 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -237,11 +267,8 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val x1 = (x + cw).toInt() | 
					 | 
					 | 
					 | 
					                    val x1 = (x + cw).toInt() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        charData = char, | 
					 | 
					 | 
					 | 
					                        charData = char, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                leftBottomPosition = Point(paddingLeft + x, paddingTop + durY), | 
					 | 
					 | 
					 | 
					                        leftBottomPosition = Point(paddingLeft + x, textLine.lineBottom), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                rightTopPosition = Point( | 
					 | 
					 | 
					 | 
					                        rightTopPosition = Point(paddingLeft + x1, textLine.lineTop) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    paddingLeft + x1, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    paddingTop + durY - (textLine.lineBottom - textLine.lineTop) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    ) | 
					 | 
					 | 
					 | 
					                    ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    x = x1 | 
					 | 
					 | 
					 | 
					                    x = x1 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -261,11 +288,8 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
					 | 
					 | 
					 | 
					                    val textChar = TextChar( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        charData = char, | 
					 | 
					 | 
					 | 
					                        charData = char, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                leftBottomPosition = Point(paddingLeft + x, paddingTop + durY), | 
					 | 
					 | 
					 | 
					                        leftBottomPosition = Point(paddingLeft + x, textLine.lineBottom), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                rightTopPosition = Point( | 
					 | 
					 | 
					 | 
					                        rightTopPosition = Point(paddingLeft + x1, textLine.lineTop) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    paddingLeft + x1, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                    paddingTop + durY - (textLine.lineBottom - textLine.lineTop) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    ) | 
					 | 
					 | 
					 | 
					                    ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
					 | 
					 | 
					 | 
					                    textLine.textChars.add(textChar) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    x = x1 | 
					 | 
					 | 
					 | 
					                    x = x1 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -273,23 +297,6 @@ object ChapterProvider { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        durY += paragraphSpacing | 
					 | 
					 | 
					 | 
					        durY += paragraphSpacing | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					        return durY | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        for ((index, item) in textPages.withIndex()) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            item.index = index | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            item.pageSize = textPages.size | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            item.chapterIndex = bookChapter.index | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            item.chapterSize = chapterSize | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            item.title = bookChapter.title | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return TextChapter( | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            bookChapter.index, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            bookChapter.title, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            bookChapter.url, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            textPages, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            pageLines, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            pageLengths, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            chapterSize | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} |