Compare commits

...

5 Commits

Author SHA1 Message Date
dependabot[bot]
2b5de041dd
Merge e1744cd36e into 576a370da1 2024-06-20 11:39:12 +08:00
Antecer
576a370da1 优化复合字体轮廓数据结构 2024-06-20 10:57:02 +08:00
Antecer
d6c2b5eceb 替换轮廓数据时忽略索引0 2024-06-20 10:54:29 +08:00
Antecer
da7093214f 修复format4字形索引gIndex参数计算错误的BUG 2024-06-19 19:00:47 +08:00
dependabot[bot]
e1744cd36e
Bump eslint from 8.57.0 to 9.5.0 in /modules/web
Bumps [eslint](https://github.com/eslint/eslint) from 8.57.0 to 9.5.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.57.0...v9.5.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 04:27:27 +00:00
3 changed files with 23 additions and 13 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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",