mirror of
https://github.com/gedoor/legado.git
synced 2024-06-30 23:06:46 +08:00
Compare commits
5 Commits
c8daac6c66
...
2b5de041dd
Author | SHA1 | Date | |
---|---|---|---|
|
2b5de041dd | ||
|
576a370da1 | ||
|
d6c2b5eceb | ||
|
da7093214f | ||
|
e1744cd36e |
|
@ -802,8 +802,9 @@ interface JsExtensions : JsEncodeUtils {
|
|||
if (errorQueryTTF.isBlankUnicode(oldCode)) {
|
||||
return@forEachIndexed
|
||||
}
|
||||
val glyf = errorQueryTTF.getGlyfByUnicode(oldCode)
|
||||
// 删除轮廓数据不存在的字符
|
||||
var glyf = errorQueryTTF.getGlyfByUnicode(oldCode) // 轮廓数据不存在
|
||||
if (errorQueryTTF.getGlyfIdByUnicode(oldCode) == 0) glyf = null; // 轮廓数据指向保留索引0
|
||||
if (filter && (glyf == null)) {
|
||||
contentArray[index] = ""
|
||||
return@forEachIndexed
|
||||
|
|
|
@ -714,7 +714,7 @@ public class QueryTTF {
|
|||
if (idRangeOffset == 0) {
|
||||
unicodeToGlyphId.put(unicode, (unicode + idDelta) & 0xFFFF);
|
||||
} else {
|
||||
int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex;
|
||||
int gIndex = (idRangeOffset / 2) + unicode - unicodeInclusive + segmentIndex - segCount;
|
||||
unicodeToGlyphId.put(unicode, gIndex < glyphIdArrayLength ? f.glyphIdArray[gIndex] + idDelta : 0);
|
||||
}
|
||||
}
|
||||
|
@ -773,12 +773,12 @@ public class QueryTTF {
|
|||
var dataTable = directorys.get("glyf");
|
||||
assert dataTable != null;
|
||||
int glyfCount = maxp.numGlyphs;
|
||||
glyfArray = new GlyfLayout[glyfCount + 1]; // 创建容器时,多创建一个作为保留区
|
||||
glyfArray = new GlyfLayout[glyfCount]; // 创建字形容器
|
||||
|
||||
var reader = new BufferReader(buffer, 0);
|
||||
for (int index = 1; index <= glyfCount; index++) {
|
||||
if (loca[index - 1] == loca[index]) continue; // 当前loca与下一个loca相同,表示这个字形不存在
|
||||
int offset = dataTable.offset + loca[index - 1];
|
||||
for (int index = 0; index < glyfCount; index++) {
|
||||
if (loca[index] == loca[index + 1]) continue; // 当前loca与下一个loca相同,表示这个字形不存在
|
||||
int offset = dataTable.offset + loca[index];
|
||||
// 读GlyphHeaders
|
||||
var glyph = new GlyfLayout();
|
||||
reader.position(offset);
|
||||
|
@ -893,7 +893,7 @@ public class QueryTTF {
|
|||
if ((glyphTableComponent.flags & 0x20) == 0) break;
|
||||
}
|
||||
}
|
||||
glyfArray[index] = glyph; // 根据文档 glyfId=0 作为保留区使用,这里赋值从索引1开始
|
||||
glyfArray[index] = glyph;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,15 @@ public class QueryTTF {
|
|||
// 复合字形
|
||||
LinkedList<String> glyphIdList = new LinkedList<>();
|
||||
for (var g : glyph.glyphComponent) {
|
||||
glyphIdList.add(String.valueOf(g.glyphIndex));
|
||||
glyphIdList.add("{" +
|
||||
"flags:" + g.flags + "," +
|
||||
"glyphIndex:" + g.glyphIndex + "," +
|
||||
"arg1:" + g.argument1 + "," +
|
||||
"arg2:" + g.argument2 + "," +
|
||||
"xScale:" + g.xScale + "," +
|
||||
"scale01:" + g.scale01 + "," +
|
||||
"scale10:" + g.scale10 + "," +
|
||||
"yScale:" + g.yScale + "}");
|
||||
}
|
||||
glyphString = "[" + String.join(",", glyphIdList) + "]";
|
||||
}
|
||||
|
@ -965,10 +973,11 @@ public class QueryTTF {
|
|||
int glyfArrayLength = glyfArray.length;
|
||||
for (var item : unicodeToGlyphId.entrySet()) {
|
||||
int key = item.getKey();
|
||||
int val = item.getValue() + 1; // glyphArray已根据TTF文档将索引0作为保留位,这里从1开始索引
|
||||
int val = item.getValue();
|
||||
if (val >= glyfArrayLength) continue;
|
||||
String glyfString = getGlyfById(val);
|
||||
unicodeToGlyph.put(key, glyfString);
|
||||
if (glyfString == null) continue; // null 不能用作hashmap的key
|
||||
glyphToUnicode.put(glyfString, key);
|
||||
}
|
||||
// Log.i("QueryTTF", "字体处理完成");
|
||||
|
@ -986,8 +995,8 @@ public class QueryTTF {
|
|||
*/
|
||||
public int getGlyfIdByUnicode(int unicode) {
|
||||
var result = unicodeToGlyphId.get(unicode);
|
||||
if (result == null) return 0;
|
||||
return result + 1; // 根据TTF文档,轮廓索引的定义从1开始
|
||||
if (result == null) return 0; // 如果找不到Unicode对应的轮廓索引,就返回默认值0
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1008,7 +1017,7 @@ public class QueryTTF {
|
|||
*/
|
||||
public int getUnicodeByGlyf(String glyph) {
|
||||
var result = glyphToUnicode.get(glyph);
|
||||
if (result == null) return 0;
|
||||
if (result == null) return 0; // 如果轮廓数据找不到对应的Unicode,就返回默认值0
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"eslint": "^8.40.0",
|
||||
"eslint": "^9.5.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-plugin-vue": "^9.12.0",
|
||||
|
|
Loading…
Reference in New Issue
Block a user