Convert the PartialEvaluator.readToUnicode method to be async

This commit is contained in:
Jonas Jenwald 2024-01-22 12:44:32 +01:00
parent f5c01188dc
commit f21a30dfb4

View File

@ -3765,28 +3765,30 @@ class PartialEvaluator {
return new IdentityToUnicodeMap(properties.firstChar, properties.lastChar);
}
readToUnicode(cmapObj) {
async readToUnicode(cmapObj) {
if (!cmapObj) {
return Promise.resolve(null);
return null;
}
if (cmapObj instanceof Name) {
return CMapFactory.create({
const cmap = await CMapFactory.create({
encoding: cmapObj,
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
useCMap: null,
}).then(function (cmap) {
});
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xffff);
}
return new ToUnicodeMap(cmap.getMap());
});
} else if (cmapObj instanceof BaseStream) {
return CMapFactory.create({
}
if (cmapObj instanceof BaseStream) {
try {
const cmap = await CMapFactory.create({
encoding: cmapObj,
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
useCMap: null,
}).then(
function (cmap) {
});
if (cmap instanceof IdentityCMap) {
return new IdentityToUnicodeMap(0, 0xffff);
}
@ -3815,8 +3817,7 @@ class PartialEvaluator {
map[charCode] = String.fromCodePoint(...str);
});
return new ToUnicodeMap(map);
},
reason => {
} catch (reason) {
if (reason instanceof AbortException) {
return null;
}
@ -3826,9 +3827,8 @@ class PartialEvaluator {
}
throw reason;
}
);
}
return Promise.resolve(null);
return null;
}
readCidToGidMap(glyphsData, toUnicode) {