Merge pull request #500 from gedoor/antecer

整合queryTTF支持base64
pull/501/head
Antecer 4 years ago committed by GitHub
commit 9208eeae54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/src/main/java/io/legado/app/help/JsExtensions.kt

@ -245,9 +245,7 @@ interface JsExtensions {
str ?: return null str ?: return null
val key = md5Encode16(str) val key = md5Encode16(str)
var qTTF = CacheManager.getQueryTTF(key) var qTTF = CacheManager.getQueryTTF(key)
if (qTTF != null) { if (qTTF != null) return qTTF
return qTTF
}
val font: ByteArray? = when { val font: ByteArray? = when {
str.isAbsUrl() -> runBlocking { str.isAbsUrl() -> runBlocking {
var x = CacheManager.getByteArray(key) var x = CacheManager.getByteArray(key)
@ -276,12 +274,12 @@ interface JsExtensions {
start: Int, start: Int,
end: Int end: Int
): String { ): String {
if (font1 == null || font2 == null) { if (font1 == null || font2 == null) return text
return text val startChar = start.toChar()
} val endChar = end.toChar()
val contentArray = text.toCharArray() val contentArray = text.toCharArray()
contentArray.forEachIndexed { index, s -> contentArray.forEachIndexed { index, s ->
if (s > start.toChar() && s < end.toChar()) { if (s in startChar until endChar) {
val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(s.toInt())) val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(s.toInt()))
contentArray[index] = code.toChar() contentArray[index] = code.toChar()
} }

Loading…
Cancel
Save