From 85b1e7b5483dd2c4bda686199933f83536e550ee Mon Sep 17 00:00:00 2001 From: Antecer Date: Thu, 20 Jun 2024 17:11:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BD=AE=E5=BB=93=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E4=B8=BA0=E7=9A=84Unicode=E6=8E=92=E9=99=A4=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/analyzeRule/QueryTTF.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 9bdbc8996..457e3539e 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 @@ -685,6 +685,7 @@ public class QueryTTF { int unicodeInclusive = 0; int unicodeExclusive = f.glyphIdArray.length; for (; unicodeInclusive < unicodeExclusive; unicodeInclusive++) { + if (f.glyphIdArray[unicodeInclusive] == 0) continue; // 排除轮廓索引为0的Unicode unicodeToGlyphId.put(unicodeInclusive, f.glyphIdArray[unicodeInclusive]); } break; @@ -711,12 +712,15 @@ public class QueryTTF { int idDelta = f.idDelta[segmentIndex]; int idRangeOffset = f.idRangeOffsets[segmentIndex]; for (int unicode = unicodeInclusive; unicode <= unicodeExclusive; unicode++) { + int glyphId = 0; if (idRangeOffset == 0) { - unicodeToGlyphId.put(unicode, (unicode + idDelta) & 0xFFFF); + glyphId = (unicode + idDelta) & 0xFFFF; } else { int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex - segCount; - unicodeToGlyphId.put(unicode, gIndex < glyphIdArrayLength ? f.glyphIdArray[gIndex] + idDelta : 0); + if (gIndex < glyphIdArrayLength) glyphId = f.glyphIdArray[gIndex] + idDelta; } + if (glyphId == 0) continue; // 排除轮廓索引为0的Unicode + unicodeToGlyphId.put(unicode, glyphId); } } break; @@ -975,7 +979,6 @@ public class QueryTTF { int key = item.getKey(); int val = item.getValue(); if (val >= glyfArrayLength) continue; - if (val == 0) continue; // 排除轮廓索引为0的Unicode String glyfString = getGlyfById(val); unicodeToGlyph.put(key, glyfString); if (glyfString == null) continue; // null 不能用作hashmap的key