pull/498/head
gedoor 4 years ago
parent d8467c3291
commit 29fc8005c7
  1. 9
      app/src/main/java/io/legado/app/help/JsExtensions.kt

@ -242,17 +242,18 @@ interface JsExtensions {
}
fun queryTTF(path: String): QueryTTF? {
var qTTF = CacheManager.getQueryTTF(path)
val key = md5Encode16(path)
var qTTF = CacheManager.getQueryTTF(key)
if (qTTF != null) {
return qTTF
}
val font: ByteArray? = when {
path.isAbsUrl() -> runBlocking {
var x = CacheManager.getByteArray(path)
var x = CacheManager.getByteArray(key)
if (x == null) {
x = HttpHelper.simpleGetBytesAsync(path)
x?.let {
CacheManager.put(path, it)
CacheManager.put(key, it)
}
}
return@runBlocking x
@ -266,7 +267,7 @@ interface JsExtensions {
}
font ?: return null
qTTF = QueryTTF(font)
CacheManager.put(path, qTTF)
CacheManager.put(key, qTTF)
return qTTF
}

Loading…
Cancel
Save