From 512dbe306076eff807ccc8780316166d3f35aac5 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Mon, 27 Jan 2020 11:03:27 +0900 Subject: [PATCH] Fix text spacing with vertical fonts. #7687 and #11526. When the writing mode is vertical, we have to reverse the sign of spacing since we are subtracting it from current.y. We have to add it to current.y. See 9.4.4 Text Space Details, https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1694762 --- src/display/canvas.js | 7 ++++++- test/pdfs/issue11526.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/issue11526.pdf.link diff --git a/src/display/canvas.js b/src/display/canvas.js index eaec1a1d5..87c21d5d3 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1719,7 +1719,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { } } - var charWidth = width * widthAdvanceScale + spacing * fontDirection; + var charWidth; + if (vertical) { + charWidth = width * widthAdvanceScale - spacing * fontDirection; + } else { + charWidth = width * widthAdvanceScale + spacing * fontDirection; + } x += charWidth; if (restoreNeeded) { diff --git a/test/pdfs/issue11526.pdf.link b/test/pdfs/issue11526.pdf.link new file mode 100644 index 000000000..866510daa --- /dev/null +++ b/test/pdfs/issue11526.pdf.link @@ -0,0 +1 @@ +https://web.archive.org/web/20200210200830/https://www.nta.go.jp/taxes/tetsuzuki/shinsei/shinkoku/zoyo/yoshiki2019/pdf/006.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index d80a1dc25..6060ef717 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -4376,5 +4376,13 @@ "rounds": 1, "link": false, "type": "eq" + }, + { "id": "issue11526", + "file": "pdfs/issue11526.pdf", + "md5": "9babc771fc8792f43e4ada46b0daff8c", + "rounds": 1, + "lastPage": 1, + "link": true, + "type": "eq" } ]