Skip to content

Commit 67b92b3

Browse files
Merge pull request #20537 from calixteman/remove_undestack
Remove undefStack stuff in the cff parser
2 parents 884cd20 + 1dffcf7 commit 67b92b3

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

src/core/cff_parser.js

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ const CharstringValidationData = [
119119
/* 7 */ { id: "vlineto", min: 1, resetStack: true },
120120
/* 8 */ { id: "rrcurveto", min: 6, resetStack: true },
121121
/* 9 */ null,
122-
/* 10 */ { id: "callsubr", min: 1, undefStack: true },
123-
/* 11 */ { id: "return", min: 0, undefStack: true },
122+
/* 10 */ { id: "callsubr", min: 1 },
123+
/* 11 */ { id: "return", min: 0 },
124124
/* 12 */ null,
125125
/* 13 */ null,
126126
/* 14 */ { id: "endchar", min: 0, stackClearing: true },
@@ -138,7 +138,7 @@ const CharstringValidationData = [
138138
/* 26 */ { id: "vvcurveto", min: 4, resetStack: true },
139139
/* 27 */ { id: "hhcurveto", min: 4, resetStack: true },
140140
/* 28 */ null, // shortint
141-
/* 29 */ { id: "callgsubr", min: 1, undefStack: true },
141+
/* 29 */ { id: "callgsubr", min: 1 },
142142
/* 30 */ { id: "vhcurveto", min: 4, resetStack: true },
143143
/* 31 */ { id: "hvcurveto", min: 4, resetStack: true },
144144
];
@@ -627,26 +627,24 @@ class CFFParser {
627627
data[j - 1] = value === 1 ? 3 : 23;
628628
}
629629
}
630-
if ("min" in validationCommand) {
631-
if (!state.undefStack && stackSize < validationCommand.min) {
632-
warn(
633-
"Not enough parameters for " +
634-
validationCommand.id +
635-
"; actual: " +
636-
stackSize +
637-
", expected: " +
638-
validationCommand.min
639-
);
640-
641-
if (stackSize === 0) {
642-
// Just "fix" the outline in replacing command by a endchar:
643-
// it could lead to wrong rendering of some glyphs or not.
644-
// For example, the pdf in #6132 is well-rendered.
645-
data[j - 1] = 14;
646-
return true;
647-
}
648-
return false;
630+
if (stackSize < validationCommand.min) {
631+
warn(
632+
"Not enough parameters for " +
633+
validationCommand.id +
634+
"; actual: " +
635+
stackSize +
636+
", expected: " +
637+
validationCommand.min
638+
);
639+
640+
if (stackSize === 0) {
641+
// Just "fix" the outline in replacing command by a endchar:
642+
// it could lead to wrong rendering of some glyphs or not.
643+
// For example, the pdf in #6132 is well-rendered.
644+
data[j - 1] = 14;
645+
return true;
649646
}
647+
return false;
650648
}
651649
if (state.firstStackClearing && validationCommand.stackClearing) {
652650
state.firstStackClearing = false;
@@ -670,15 +668,11 @@ class CFFParser {
670668
validationCommand.stackFn(stack, stackSize);
671669
}
672670
stackSize += validationCommand.stackDelta;
673-
} else if (validationCommand.stackClearing) {
674-
stackSize = 0;
675-
} else if (validationCommand.resetStack) {
676-
stackSize = 0;
677-
state.undefStack = false;
678-
} else if (validationCommand.undefStack) {
671+
} else if (
672+
validationCommand.stackClearing ||
673+
validationCommand.resetStack
674+
) {
679675
stackSize = 0;
680-
state.undefStack = true;
681-
state.firstStackClearing = false;
682676
}
683677
}
684678
}
@@ -706,7 +700,6 @@ class CFFParser {
706700
callDepth: 0,
707701
stackSize: 0,
708702
stack: [],
709-
undefStack: true,
710703
hints: 0,
711704
firstStackClearing: true,
712705
seac: null,

0 commit comments

Comments
 (0)