重构QueryTTF功能
This commit is contained in:
@@ -775,7 +775,7 @@ interface JsExtensions : JsEncodeUtils {
|
|||||||
}
|
}
|
||||||
font ?: return null
|
font ?: return null
|
||||||
qTTF = QueryTTF(font)
|
qTTF = QueryTTF(font)
|
||||||
CacheManager.put(key, qTTF)
|
CacheManager.put(key, qTTF) // debug注释掉
|
||||||
return qTTF
|
return qTTF
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
AppLog.put("获取字体处理类出错", e)
|
AppLog.put("获取字体处理类出错", e)
|
||||||
@@ -798,15 +798,21 @@ interface JsExtensions : JsEncodeUtils {
|
|||||||
val contentArray = text.toStringArray() //这里不能用toCharArray,因为有些文字占多个字节
|
val contentArray = text.toStringArray() //这里不能用toCharArray,因为有些文字占多个字节
|
||||||
contentArray.forEachIndexed { index, s ->
|
contentArray.forEachIndexed { index, s ->
|
||||||
val oldCode = s.codePointAt(0)
|
val oldCode = s.codePointAt(0)
|
||||||
val glyf = errorQueryTTF.getGlyfByCode(oldCode)
|
// 忽略正常的空白字符
|
||||||
val code = correctQueryTTF.getCodeByGlyf(glyf)
|
if (errorQueryTTF.isBlankUnicode(oldCode)) {
|
||||||
|
return@forEachIndexed
|
||||||
|
}
|
||||||
|
val glyf = errorQueryTTF.getGlyfByUnicode(oldCode)
|
||||||
|
// 删除轮廓数据不存在的字符
|
||||||
|
if (filter && (glyf == null)) {
|
||||||
|
contentArray[index] = ""
|
||||||
|
return@forEachIndexed
|
||||||
|
}
|
||||||
|
// 使用轮廓数据反查Unicode
|
||||||
|
val code = correctQueryTTF.getUnicodeByGlyf(glyf)
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
contentArray[index] = code.toChar().toString()
|
contentArray[index] = code.toChar().toString()
|
||||||
}
|
}
|
||||||
if (glyf.equals("") && filter) {
|
|
||||||
// 删除轮廓数据为空的字符
|
|
||||||
contentArray[index] = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return contentArray.joinToString("")
|
return contentArray.joinToString("")
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user