|
|
@ -244,9 +244,7 @@ interface JsExtensions { |
|
|
|
fun queryTTF(path: String): QueryTTF? { |
|
|
|
fun queryTTF(path: String): QueryTTF? { |
|
|
|
val key = md5Encode16(path) |
|
|
|
val key = md5Encode16(path) |
|
|
|
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 { |
|
|
|
path.isAbsUrl() -> runBlocking { |
|
|
|
var x = CacheManager.getByteArray(key) |
|
|
|
var x = CacheManager.getByteArray(key) |
|
|
@ -261,9 +259,12 @@ interface JsExtensions { |
|
|
|
path.isContentScheme() -> { |
|
|
|
path.isContentScheme() -> { |
|
|
|
Uri.parse(path).readBytes(App.INSTANCE) |
|
|
|
Uri.parse(path).readBytes(App.INSTANCE) |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
path.startsWith("/storage")->{ |
|
|
|
File(path).readBytes() |
|
|
|
File(path).readBytes() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
base64DecodeToByteArray(path.removePrefix("base64,")) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
font ?: return null |
|
|
|
font ?: return null |
|
|
|
qTTF = QueryTTF(font) |
|
|
|
qTTF = QueryTTF(font) |
|
|
@ -278,12 +279,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() |
|
|
|
} |
|
|
|
} |
|
|
|