diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 97958faa6..45c65074b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1009,16 +1009,23 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // var x = pt[0]; // var y = pt[1]; + var charSpacing = 0; + if (textChunk.str.length > 0) { + // Apply char spacing only when there are chars. + // As a result there is only spacing between glyphs. + charSpacing = textState.charSpacing; + } + var tx = 0; var ty = 0; if (!font.vertical) { var w0 = glyphWidth * textState.fontMatrix[0]; - tx = (w0 * textState.fontSize + textState.charSpacing) * + tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale; width += tx; } else { var w1 = glyphWidth * textState.fontMatrix[0]; - ty = w1 * textState.fontSize + textState.charSpacing; + ty = w1 * textState.fontSize + charSpacing; height += ty; } textState.translateTextMatrix(tx, ty); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 47285d193..eb1127aa7 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -6,6 +6,7 @@ !issue2391-1.pdf !issue2391-2.pdf !issue5801.pdf +!issue5972.pdf !filled-background.pdf !ArabicCIDTrueType.pdf !ThuluthFeatures.pdf diff --git a/test/pdfs/issue5972.pdf b/test/pdfs/issue5972.pdf new file mode 100644 index 000000000..cc00e118e --- /dev/null +++ b/test/pdfs/issue5972.pdf @@ -0,0 +1,76 @@ +%PDF-1.7 +%âãÏÓ +1 0 obj +<< +/Type /Encoding +/BaseEncoding /WinAnsiEncoding +>> +endobj +2 0 obj +<< +/Pages 3 0 R +/Type /Catalog +>> +endobj +3 0 obj +<< +/MediaBox [0 0 200 50] +/Kids [4 0 R] +/Count 1 +/Type /Pages +>> +endobj +4 0 obj +<< +/Parent 3 0 R +/MediaBox [0 0 200 50] +/Resources +<< +/Font +<< +/F1 5 0 R +>> +>> +/Contents 6 0 R +/Type /Page +>> +endobj +5 0 obj +<< +/BaseFont /Times-Italic +/Subtype /Type1 +/Encoding 1 0 R +/Type /Font +>> +endobj +6 0 obj +<< +/Length 73 +>> +stream +BT +10 15 TD +/F1 40 Tf +-8 Tc +[ (f) 20 (ore) 15 (w) 20 (or) 20 (d) ] TJ +ET + +endstream +endobj xref +0 7 +0000000000 65535 f +0000000015 00000 n +0000000085 00000 n +0000000136 00000 n +0000000218 00000 n +0000000347 00000 n +0000000438 00000 n +trailer + +<< +/Root 2 0 R +/Size 7 +>> +startxref +563 +%%EOF diff --git a/test/test_manifest.json b/test/test_manifest.json index 265259568..9248f8da9 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1095,6 +1095,13 @@ "link": false, "type": "eq" }, + { "id": "issue5972", + "file": "pdfs/issue5972.pdf", + "md5": "51f03e1d38410b04c9dda7e75fe8a0a3", + "rounds": 1, + "link": false, + "type": "text" + }, { "id": "pdfkit_compressed", "file": "pdfs/pdfkit_compressed.pdf", "md5": "ffe9c571d0a1572e234253e6c7cdee6c",