From 53b18e18e366378b6f5eda2b65d7ed45083e9462 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 27 Jan 2022 22:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/JsExtensions.kt | 8 ++++---- .../java/io/legado/app/model/analyzeRule/QueryTTF.java | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 3a1c20fa6..b6679976a 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -496,14 +496,14 @@ interface JsExtensions { correctQueryTTF: QueryTTF? ): String { if (errorQueryTTF == null || correctQueryTTF == null) return text - val contentArray = text.toCharArray() + val contentArray = text.toStringArray() contentArray.forEachIndexed { index, s -> - val oldCode = s.code - if (errorQueryTTF.inLimit(s)) { + val oldCode = s.codePointAt(0) + if (errorQueryTTF.inLimit(oldCode)) { val glyf = errorQueryTTF.getGlyfByCode(oldCode) val code = correctQueryTTF.getCodeByGlyf(glyf) if (code != 0) { - contentArray[index] = code.toChar() + contentArray[index] = code.toChar().toString() } } } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/QueryTTF.java b/app/src/main/java/io/legado/app/model/analyzeRule/QueryTTF.java index c65e3ecc6..cbd717ebd 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/QueryTTF.java +++ b/app/src/main/java/io/legado/app/model/analyzeRule/QueryTTF.java @@ -479,6 +479,8 @@ public class QueryTTF { for (short b : glyf.get(gid).yCoordinates) sb.append(b); String val = sb.toString(); if (limitMix == 0) limitMix = key; + if (limitMix > key) limitMix = key; + if (limitMax < key) limitMax = key; limitMax = key; codeToGlyph.put(key, val); if (glyphToCode.containsKey(val)) continue; @@ -576,7 +578,7 @@ public class QueryTTF { * @param code 传入Unicode十进制值 * @return 返回bool查询结果 */ - public boolean inLimit(char code) { + public boolean inLimit(int code) { return (limitMix <= code) && (code < limitMax); }