Skip to content

Commit

Permalink
Update src/core/default_appearance.js
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Jenwald <[email protected]>
  • Loading branch information
calixteman and Snuffleupagus authored Jan 15, 2021
1 parent cc70c47 commit ddcfa03
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions src/core/default_appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,37 @@ class DefaultAppearanceEvaluator extends EvaluatorPreprocessor {
fontColor: new Uint8ClampedArray([0, 0, 0]) /* black */,
};

while (this.read(operation)) {
if (this.stateManager.stateStack.length !== 0) {
// Don't get info in save/restore sections.
continue;
try {
while (this.read(operation)) {
if (this.stateManager.stateStack.length !== 0) {
// Don't get info in save/restore sections.
continue;
}
const { fn, args } = operation;
switch (fn | 0) {
case OPS.setFont:
const [fontName, fontSize] = args;
if (isName(fontName)) {
result.fontName = fontName;
}
if (typeof fontSize === "number" && fontSize > 0) {
result.fontSize = fontSize;
}
break;
case OPS.setFillRGBColor:
ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
break;
case OPS.setFillGray:
ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
break;
case OPS.setFillColorSpace:
ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
break;
}
args.length = 0;
}
const { fn, args } = operation;
switch (fn | 0) {
case OPS.setFont:
const [fontName, fontSize] = args;
if (isName(fontName)) {
result.fontName = fontName;
}
if (typeof fontSize === "number" && fontSize > 0) {
result.fontSize = fontSize;
}
break;
case OPS.setFillRGBColor:
ColorSpace.singletons.rgb.getRgbItem(args, 0, result.fontColor, 0);
break;
case OPS.setFillGray:
ColorSpace.singletons.gray.getRgbItem(args, 0, result.fontColor, 0);
break;
case OPS.setFillColorSpace:
ColorSpace.singletons.cmyk.getRgbItem(args, 0, result.fontColor, 0);
break;
}
args.length = 0;
} catch (reason) {
warn(`parseDefaultAppearance - ignoring errors: "${reason}".`);
}

return result;
Expand Down

0 comments on commit ddcfa03

Please sign in to comment.