|
|
@ -241,29 +241,27 @@ interface JsExtensions { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun queryTTF(path: String): QueryTTF? { |
|
|
|
fun queryTTF(str: String?): QueryTTF? { |
|
|
|
val key = md5Encode16(path) |
|
|
|
str ?: return null |
|
|
|
|
|
|
|
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 { |
|
|
|
path.isAbsUrl() -> runBlocking { |
|
|
|
str.isAbsUrl() -> runBlocking { |
|
|
|
var x = CacheManager.getByteArray(key) |
|
|
|
var x = CacheManager.getByteArray(key) |
|
|
|
if (x == null) { |
|
|
|
if (x == null) { |
|
|
|
x = HttpHelper.simpleGetBytesAsync(path) |
|
|
|
x = HttpHelper.simpleGetBytesAsync(str) |
|
|
|
x?.let { |
|
|
|
x?.let { |
|
|
|
CacheManager.put(key, it) |
|
|
|
CacheManager.put(key, it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return@runBlocking x |
|
|
|
return@runBlocking x |
|
|
|
} |
|
|
|
} |
|
|
|
path.isContentScheme() -> { |
|
|
|
str.isContentScheme() -> Uri.parse(str).readBytes(App.INSTANCE) |
|
|
|
Uri.parse(path).readBytes(App.INSTANCE) |
|
|
|
str.startsWith("/storage") -> File(str).readBytes() |
|
|
|
} |
|
|
|
else -> base64DecodeToByteArray(str) |
|
|
|
else -> { |
|
|
|
|
|
|
|
File(path).readBytes() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
font ?: return null |
|
|
|
font ?: return null |
|
|
|
qTTF = QueryTTF(font) |
|
|
|
qTTF = QueryTTF(font) |
|
|
|