From dc9ce168c19e9857e11be72200693a8710446e00 Mon Sep 17 00:00:00 2001 From: Antecer Date: Tue, 18 Jun 2024 17:07:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTTF=E5=AD=97=E4=BD=93loca?= =?UTF-8?q?=E8=A1=A8=E8=AF=86=E5=88=AB=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/analyzeRule/QueryTTF.java | 5 +++++ 1 file changed, 5 insertions(+) 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 6a7ee39fd..027881ad5 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 @@ -648,6 +648,8 @@ public class QueryTTF { var reader = new BufferReader(buffer, dataTable.offset); if (head.indexToLocFormat == 0) { loca = reader.ReadUInt16Array(dataTable.length / 2); + // 当loca表数据长度为Uint16时,需要翻倍 + for (var i = 0; i < loca.length; i++) loca[i] *= 2; } else { loca = reader.ReadInt32Array(dataTable.length / 4); } @@ -781,11 +783,14 @@ public class QueryTTF { var glyph = new GlyfLayout(); reader.position(offset); glyph.numberOfContours = reader.ReadInt16(); + if (glyph.numberOfContours > maxp.maxContours) continue; // 如果字形轮廓数大于非复合字形中包含的最大轮廓数,则说明该字形无效。 glyph.xMin = reader.ReadInt16(); glyph.yMin = reader.ReadInt16(); glyph.xMax = reader.ReadInt16(); glyph.yMax = reader.ReadInt16(); + // 轮廓数为0时,不需要解析轮廓数据 + if (glyph.numberOfContours == 0) continue; // 读Glyph轮廓数据 if (glyph.numberOfContours > 0) { // 简单轮廓