Skip to content

Commit

Permalink
Do the isType3Font-check *once*, rather than repeating it, in `Part…
Browse files Browse the repository at this point in the history
…ialEvaluator.translateFont`

*This is a small piece of clean-up that I happened to notice while browsing the code.*
  • Loading branch information
Snuffleupagus committed May 22, 2021
1 parent 318d665 commit ea9cb8a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3672,10 +3672,11 @@ class PartialEvaluator {
toUnicode,
cssFontInfo,
}) {
const isType3Font = type === "Type3";
let properties;

if (!descriptor) {
if (type === "Type3") {
if (isType3Font) {
// FontDescriptor is only required for Type3 fonts when the document
// is a tagged pdf. Create a barbebones one to get by.
descriptor = new Dict(null);
Expand Down Expand Up @@ -3712,6 +3713,7 @@ class PartialEvaluator {
firstChar,
lastChar,
toUnicode,
isType3Font,
};
const widths = dict.get("Widths");
return this.extractDataStructures(dict, dict, properties).then(
Expand Down Expand Up @@ -3751,7 +3753,7 @@ class PartialEvaluator {
baseFont = Name.get(baseFont);
}

if (type !== "Type3") {
if (!isType3Font) {
const fontNameStr = fontName && fontName.name;
const baseFontStr = baseFont && baseFont.name;
if (fontNameStr !== baseFontStr) {
Expand Down Expand Up @@ -3816,7 +3818,7 @@ class PartialEvaluator {
capHeight: descriptor.get("CapHeight"),
flags: descriptor.get("Flags"),
italicAngle: descriptor.get("ItalicAngle"),
isType3Font: false,
isType3Font,
cssFontInfo,
};

Expand All @@ -3838,9 +3840,6 @@ class PartialEvaluator {
newProperties => {
this.extractWidths(dict, descriptor, newProperties);

if (type === "Type3") {
newProperties.isType3Font = true;
}
return new Font(fontName.name, fontFile, newProperties);
}
);
Expand Down

0 comments on commit ea9cb8a

Please sign in to comment.