Export the firstChar
/lastChar
-data from PartialEvaluator.preEvaluateFont
Rather than re-fetching/re-parsing these properties immediately in `PartialEvaluator.translateFont`, we can simply export them instead. (Obviously the effect will be really tiny, but there is less parsing overall this way.)
This commit is contained in:
parent
e6435e37af
commit
13fb1654dc
@ -3563,10 +3563,13 @@ class PartialEvaluator {
|
|||||||
composite = true;
|
composite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const firstChar = dict.get("FirstChar") || 0,
|
||||||
|
lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
|
||||||
const descriptor = dict.get("FontDescriptor");
|
const descriptor = dict.get("FontDescriptor");
|
||||||
let hash;
|
let hash;
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
hash = new MurmurHash3_64();
|
hash = new MurmurHash3_64();
|
||||||
|
|
||||||
const encoding = baseDict.getRaw("Encoding");
|
const encoding = baseDict.getRaw("Encoding");
|
||||||
if (isName(encoding)) {
|
if (isName(encoding)) {
|
||||||
hash.update(encoding.name);
|
hash.update(encoding.name);
|
||||||
@ -3596,9 +3599,7 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstChar = dict.get("FirstChar") || 0;
|
hash.update(`${firstChar}-${lastChar}`); // Fixes issue10665_reduced.pdf
|
||||||
const lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
|
|
||||||
hash.update(`${firstChar}-${lastChar}`);
|
|
||||||
|
|
||||||
const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
||||||
if (isStream(toUnicode)) {
|
if (isStream(toUnicode)) {
|
||||||
@ -3656,6 +3657,8 @@ class PartialEvaluator {
|
|||||||
baseDict,
|
baseDict,
|
||||||
composite,
|
composite,
|
||||||
type: type.name,
|
type: type.name,
|
||||||
|
firstChar,
|
||||||
|
lastChar,
|
||||||
hash: hash ? hash.hexdigest() : "",
|
hash: hash ? hash.hexdigest() : "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -3666,10 +3669,9 @@ class PartialEvaluator {
|
|||||||
const composite = preEvaluatedFont.composite;
|
const composite = preEvaluatedFont.composite;
|
||||||
let descriptor = preEvaluatedFont.descriptor;
|
let descriptor = preEvaluatedFont.descriptor;
|
||||||
const type = preEvaluatedFont.type;
|
const type = preEvaluatedFont.type;
|
||||||
const maxCharIndex = composite ? 0xffff : 0xff;
|
const firstChar = preEvaluatedFont.firstChar,
|
||||||
|
lastChar = preEvaluatedFont.lastChar;
|
||||||
let properties;
|
let properties;
|
||||||
const firstChar = dict.get("FirstChar") || 0;
|
|
||||||
const lastChar = dict.get("LastChar") || maxCharIndex;
|
|
||||||
|
|
||||||
if (!descriptor) {
|
if (!descriptor) {
|
||||||
if (type === "Type3") {
|
if (type === "Type3") {
|
||||||
@ -3802,8 +3804,8 @@ class PartialEvaluator {
|
|||||||
composite,
|
composite,
|
||||||
fixedPitch: false,
|
fixedPitch: false,
|
||||||
fontMatrix: dict.getArray("FontMatrix") || FONT_IDENTITY_MATRIX,
|
fontMatrix: dict.getArray("FontMatrix") || FONT_IDENTITY_MATRIX,
|
||||||
firstChar: firstChar || 0,
|
firstChar,
|
||||||
lastChar: lastChar || maxCharIndex,
|
lastChar,
|
||||||
bbox: descriptor.getArray("FontBBox"),
|
bbox: descriptor.getArray("FontBBox"),
|
||||||
ascent: descriptor.get("Ascent"),
|
ascent: descriptor.get("Ascent"),
|
||||||
descent: descriptor.get("Descent"),
|
descent: descriptor.get("Descent"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user