Skip to content

Commit

Permalink
Fix issue with space offsets in TJs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalley Powell authored and kalley committed Oct 14, 2015
1 parent 2096a2a commit 726beb4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
});
}

function buildTextGeometry(chars, textChunk) {
function buildTextGeometry(chars, textChunk, previousChars) {
var font = textState.font;
var offset = (isNum(previousChars) ? previousChars / 1000 : 0);
textChunk = textChunk || newTextChunk();
if (!textChunk.transform) {
// 9.4.4 Text Space Details
Expand Down Expand Up @@ -1036,17 +1037,19 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var ty = 0;
if (!font.vertical) {
var w0 = glyphWidth * textState.fontMatrix[0];
tx = (w0 * textState.fontSize + charSpacing) *
tx = ((w0 - offset) * textState.fontSize + charSpacing) *
textState.textHScale;
width += tx;
} else {
var w1 = glyphWidth * textState.fontMatrix[0];
ty = w1 * textState.fontSize + charSpacing;
ty = (w1 - offset) * textState.fontSize + charSpacing;
height += ty;
}
textState.translateTextMatrix(tx, ty);

textChunk.str.push(glyphUnicode);

offset = 0;
}

var a = textState.textLineMatrix[0];
Expand Down Expand Up @@ -1130,7 +1133,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var offset;
for (var j = 0, jj = items.length; j < jj; j++) {
if (typeof items[j] === 'string') {
buildTextGeometry(items[j], textChunk);
buildTextGeometry(items[j], textChunk,
(j > 0 ? items[j - 1] : 0));
} else {
// PDF Specification 5.3.2 states:
// The number is expressed in thousandths of a unit of text
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
!issue1171.pdf
!smaskdim.pdf
!endchar.pdf
!pr6019.pdf
!type4psfunc.pdf
!issue1350.pdf
!S2.pdf
Expand Down
Binary file added test/pdfs/pr6019.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "pr6019",
"file": "pdfs/pr6019.pdf",
"md5": "7a2e5dda3b0fc5c2e9060e378a8cdc4e",
"rounds": 1,
"type": "text",
"link": false
},
{ "id": "type4psfunc",
"file": "pdfs/type4psfunc.pdf",
"md5": "7e6027a02ff78577f74dccdf84e37189",
Expand Down

0 comments on commit 726beb4

Please sign in to comment.