Merge pull request #14500 from calixteman/14497
Take into account all rotations before comparing glyph positions
This commit is contained in:
commit
a69adf0382
@ -2385,6 +2385,14 @@ class PartialEvaluator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyInverseRotation(x, y, matrix) {
|
||||||
|
const scale = Math.hypot(matrix[0], matrix[1]);
|
||||||
|
return [
|
||||||
|
(matrix[0] * x + matrix[1] * y) / scale,
|
||||||
|
(matrix[2] * x + matrix[3] * y) / scale,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function compareWithLastPosition() {
|
function compareWithLastPosition() {
|
||||||
if (
|
if (
|
||||||
!combineTextItems ||
|
!combineTextItems ||
|
||||||
@ -2404,9 +2412,8 @@ class PartialEvaluator {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rotate = 0;
|
let rotate = -1;
|
||||||
// Take into account the rotation is the current transform.
|
// Take into account the rotation is the current transform.
|
||||||
// Only rotations with an angle of 0, 90, 180 or 270 are considered.
|
|
||||||
if (
|
if (
|
||||||
currentTransform[0] &&
|
currentTransform[0] &&
|
||||||
currentTransform[1] === 0 &&
|
currentTransform[1] === 0 &&
|
||||||
@ -2418,28 +2425,40 @@ class PartialEvaluator {
|
|||||||
currentTransform[0] === 0 &&
|
currentTransform[0] === 0 &&
|
||||||
currentTransform[3] === 0
|
currentTransform[3] === 0
|
||||||
) {
|
) {
|
||||||
rotate += currentTransform[1] > 0 ? 90 : 270;
|
rotate = currentTransform[1] > 0 ? 90 : 270;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotate !== 0) {
|
switch (rotate) {
|
||||||
switch (rotate) {
|
case 0:
|
||||||
case 90:
|
break;
|
||||||
[posX, posY] = [posY, posX];
|
case 90:
|
||||||
[lastPosX, lastPosY] = [lastPosY, lastPosX];
|
[posX, posY] = [posY, posX];
|
||||||
break;
|
[lastPosX, lastPosY] = [lastPosY, lastPosX];
|
||||||
case 180:
|
break;
|
||||||
[posX, posY, lastPosX, lastPosY] = [
|
case 180:
|
||||||
-posX,
|
[posX, posY, lastPosX, lastPosY] = [
|
||||||
-posY,
|
-posX,
|
||||||
-lastPosX,
|
-posY,
|
||||||
-lastPosY,
|
-lastPosX,
|
||||||
];
|
-lastPosY,
|
||||||
break;
|
];
|
||||||
case 270:
|
break;
|
||||||
[posX, posY] = [-posY, -posX];
|
case 270:
|
||||||
[lastPosX, lastPosY] = [-lastPosY, -lastPosX];
|
[posX, posY] = [-posY, -posX];
|
||||||
break;
|
[lastPosX, lastPosY] = [-lastPosY, -lastPosX];
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
// This is not a 0, 90, 180, 270 rotation so:
|
||||||
|
// - remove the scale factor from the matrix to get a rotation matrix
|
||||||
|
// - apply the inverse (which is the transposed) to the positions
|
||||||
|
// and we can then compare positions of the glyphes to detect
|
||||||
|
// a whitespace.
|
||||||
|
[posX, posY] = applyInverseRotation(posX, posY, currentTransform);
|
||||||
|
[lastPosX, lastPosY] = applyInverseRotation(
|
||||||
|
lastPosX,
|
||||||
|
lastPosY,
|
||||||
|
textContentItem.prevTransform
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textState.font.vertical) {
|
if (textState.font.vertical) {
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -506,3 +506,4 @@
|
|||||||
!poppler-90-0-fuzzed.pdf
|
!poppler-90-0-fuzzed.pdf
|
||||||
!issue14415.pdf
|
!issue14415.pdf
|
||||||
!issue14307.pdf
|
!issue14307.pdf
|
||||||
|
!issue14497.pdf
|
||||||
|
BIN
test/pdfs/issue14497.pdf
Executable file
BIN
test/pdfs/issue14497.pdf
Executable file
Binary file not shown.
@ -6238,5 +6238,11 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"lastPage": 1,
|
"lastPage": 1,
|
||||||
"type": "text"
|
"type": "text"
|
||||||
|
},
|
||||||
|
{ "id": "issue14497",
|
||||||
|
"file": "pdfs/issue14497.pdf",
|
||||||
|
"md5": "7f795a92caa612117b6928f8bb4c5b65",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "text"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user