pull/497/head
gedoor 4 years ago
parent eae9354e70
commit 1eae98fc27
  1. 4
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  2. 15
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt

@ -298,7 +298,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
return ArrayList()
}
fun getByteArray(ruleStr: String): ByteArray? {
fun getResult(ruleStr: String): Any? {
if (ruleStr.isEmpty()) return null
val ruleList = splitSourceRule(ruleStr)
var result: Any? = null
@ -323,7 +323,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
}
}
}
return result as? ByteArray
return result
}
/**

@ -39,16 +39,16 @@ object BookContent {
val fontRule = contentRule.font
val correctFontRule = contentRule.correctFont
var font: ByteArray? = null
var correctFont: ByteArray? = null
var cQueryTTF: QueryTTF? = null
fontRule?.let {
//todo 获取网页嵌入字体
font = analyzeRule.getByteArray(it)
font = analyzeRule.getResult(it) as? ByteArray
}
correctFontRule?.let {
//todo 获取正确字体
correctFont = analyzeRule.getByteArray(it)
cQueryTTF = analyzeRule.getResult(it) as? QueryTTF
}
if (correctFont == null && font != null) {
if (cQueryTTF == null && font != null) {
BookHelp.saveFont(book, bookChapter, font!!)
}
var contentData = analyzeContent(
@ -114,13 +114,12 @@ object BookContent {
analyzeRule.chapter = bookChapter
contentStr = analyzeRule.getString(replaceRegex)
}
if (correctFont != null && font != null) {
if (cQueryTTF != null && font != null) {
val queryTTF = QueryTTF(font!!)
val cQueryTTF = QueryTTF(correctFont!!)
val contentArray = contentStr.toCharArray()
contentArray.forEachIndexed { index, s ->
if(s> 58000.toChar()){
val code = cQueryTTF.GetCodeByGlyf(queryTTF.GetGlyfByCode(s.toInt()))
if (s > 58000.toChar()) {
val code = cQueryTTF!!.GetCodeByGlyf(queryTTF.GetGlyfByCode(s.toInt()))
contentArray[index] = code.toChar()
}
}

Loading…
Cancel
Save