Skip to content

Commit

Permalink
Merge pull request #16 from veraPDF/the-glyph-has-no-unicode-value
Browse files Browse the repository at this point in the history
The glyph has no Unicode value
  • Loading branch information
Vladimir-Burshnev authored Feb 23, 2024
2 parents 48271dc + 4e26246 commit 5ccd3c5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
28 changes: 24 additions & 4 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ class Annotation {
this.setColor(dict.getArray("C"));
this.setBorderStyle(dict);
this.setAppearance(dict);
this.initAppearancePos = this.appearance?.pos;
this.setOptionalContent(dict);

const MK = dict.get("MK");
Expand Down Expand Up @@ -921,8 +922,10 @@ class Annotation {
isUsingOwnCanvas,
]);

await evaluator.getOperatorList({
const [MCIDBBoxes, opPos, noMCIDBBoxes] = await evaluator.getOperatorList({
initStreamPos: this.initAppearancePos,
stream: appearance,
intent,
task,
resources,
operatorList: opList,
Expand All @@ -934,7 +937,15 @@ class Annotation {
opList.addOp(OPS.endMarkedContent, []);
}
this.reset();
return { opList, separateForm: false, separateCanvas: isUsingOwnCanvas };
return {
opList,
separateForm: false,
separateCanvas: isUsingOwnCanvas,
annotBBoxesAndOpPos: {
operationPosition: opPos,
boundingBoxes: [MCIDBBoxes, noMCIDBBoxes],
},
};
}

async save(evaluator, task, annotationStorage) {
Expand Down Expand Up @@ -1743,7 +1754,8 @@ class WidgetAnnotation extends Annotation {
]);

const stream = new StringStream(content);
await evaluator.getOperatorList({
const [MCIDBBoxes, opPos, noMCIDBBoxes] = await evaluator.getOperatorList({
intent,
stream,
task,
resources: this._fieldResources.mergedResources,
Expand All @@ -1754,7 +1766,15 @@ class WidgetAnnotation extends Annotation {
if (optionalContent !== undefined) {
opList.addOp(OPS.endMarkedContent, []);
}
return { opList, separateForm: false, separateCanvas: false };
return {
opList,
separateForm: false,
separateCanvas: false,
annotBBoxesAndOpPos: {
operationPosition: opPos,
boundingBoxes: [MCIDBBoxes, noMCIDBBoxes],
},
};
}

_getMKDict(rotation) {
Expand Down
12 changes: 11 additions & 1 deletion src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ class Page {
intent & RenderingIntentFlag.ANNOTATIONS_DISABLE
) {
if (intent & RenderingIntentFlag.OPLIST) {
pageOpList.addOp(OPS.annotBBoxesAndOpPos, []);
pageOpList.addOp(OPS.operationPosition, positionByOperationIndex);
pageOpList.addOp(OPS.boundingBoxes, [MCIDBoundingBoxes, noMCIDBoundingBoxes]);
}
Expand Down Expand Up @@ -507,7 +508,8 @@ class Page {
let form = false,
canvas = false;

for (const { opList, separateForm, separateCanvas } of opLists) {
const annotationsBBoxesAndOperationPosition = [];
for (const { opList, separateForm, separateCanvas, annotBBoxesAndOpPos } of opLists) {
pageOpList.addOpList(opList);

if (separateForm) {
Expand All @@ -516,8 +518,16 @@ class Page {
if (separateCanvas) {
canvas = separateCanvas;
}

annotationsBBoxesAndOperationPosition.push(
annotBBoxesAndOpPos ? [
annotBBoxesAndOpPos.operationPosition,
annotBBoxesAndOpPos.boundingBoxes,
] : []
);
}
if (intent & RenderingIntentFlag.OPLIST) {
pageOpList.addOp(OPS.annotBBoxesAndOpPos, annotationsBBoxesAndOperationPosition);
pageOpList.addOp(OPS.operationPosition, positionByOperationIndex);
pageOpList.addOp(OPS.boundingBoxes, [
MCIDBoundingBoxes,
Expand Down
5 changes: 5 additions & 0 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,7 @@ class PartialEvaluator {
}

getOperatorList({
initStreamPos,
stream,
task,
resources,
Expand All @@ -1657,6 +1658,8 @@ class PartialEvaluator {
var self = this;
var xref = this.xref;
let parsingText = false;
let prevStreamPos;
if (initStreamPos != null) stream.pos = initStreamPos;
const localImageCache = new LocalImageCache();
const localColorSpaceCache = new LocalColorSpaceCache();
const localGStateCache = new LocalGStateCache();
Expand Down Expand Up @@ -1691,6 +1694,7 @@ class PartialEvaluator {
const operation = {};
let stop, i, ii, cs, name, isValidName;
while (!(stop = timeSlotManager.check())) {
if (prevStreamPos) stream.pos = prevStreamPos;
// The arguments parsed by read() are used beyond this loop, so we
// cannot reuse the same array on each iteration. Therefore we pass
// in |null| as the initial value (see the comment on
Expand All @@ -1703,6 +1707,7 @@ class PartialEvaluator {
let fn = operation.fn;
boundingBoxCalculator.incrementOperation(fn);

prevStreamPos = stream.pos;
switch (fn | 0) {
case OPS.paintXObject:
// eagerly compile XForm objects
Expand Down
3 changes: 2 additions & 1 deletion src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ const OPS = {
paintSolidColorImageMask: 90,
constructPath: 91,
boundingBoxes: 100,
operationPosition: 101
operationPosition: 101,
annotBBoxesAndOpPos: 102,
};

const UNSUPPORTED_FEATURES = {
Expand Down

0 comments on commit 5ccd3c5

Please sign in to comment.