|
|
@ -482,21 +482,21 @@ interface JsExtensions { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param text 包含错误字体的内容 |
|
|
|
* @param text 包含错误字体的内容 |
|
|
|
* @param font1 错误的字体 |
|
|
|
* @param errorQueryTTF 错误的字体 |
|
|
|
* @param font2 正确的字体 |
|
|
|
* @param correctQueryTTF 正确的字体 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun replaceFont( |
|
|
|
fun replaceFont( |
|
|
|
text: String, |
|
|
|
text: String, |
|
|
|
font1: QueryTTF?, |
|
|
|
errorQueryTTF: QueryTTF?, |
|
|
|
font2: QueryTTF? |
|
|
|
correctQueryTTF: QueryTTF? |
|
|
|
): String { |
|
|
|
): String { |
|
|
|
if (font1 == null || font2 == null) return text |
|
|
|
if (errorQueryTTF == null || correctQueryTTF == null) return text |
|
|
|
val contentArray = text.toCharArray() |
|
|
|
val contentArray = text.toCharArray() |
|
|
|
contentArray.forEachIndexed { index, s -> |
|
|
|
contentArray.forEachIndexed { index, s -> |
|
|
|
val oldCode = s.code |
|
|
|
val oldCode = s.code |
|
|
|
if (font1.inLimit(s)) { |
|
|
|
if (errorQueryTTF.inLimit(s)) { |
|
|
|
val glyf = font1.getGlyfByCode(oldCode) |
|
|
|
val glyf = errorQueryTTF.getGlyfByCode(oldCode) |
|
|
|
val code = font2.getCodeByGlyf(glyf) |
|
|
|
val code = correctQueryTTF.getCodeByGlyf(glyf) |
|
|
|
if (code != 0) { |
|
|
|
if (code != 0) { |
|
|
|
contentArray[index] = code.toChar() |
|
|
|
contentArray[index] = code.toChar() |
|
|
|
} |
|
|
|
} |
|
|
|