diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 6ed0c0319..e5bfcd477 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2948,9 +2948,12 @@ class PartialEvaluator { } const font = textState.font; + const baseCharSpacing = font.vertical + ? -textState.charSpacing + : textState.charSpacing; if (!chars) { // Just move according to the space we have. - const charSpacing = textState.charSpacing + extraSpacing; + const charSpacing = baseCharSpacing + extraSpacing; if (charSpacing) { if (!font.vertical) { textState.translateTextMatrix( @@ -2979,8 +2982,7 @@ class PartialEvaluator { if (category.isInvisibleFormatMark) { continue; } - let charSpacing = - textState.charSpacing + (i + 1 === ii ? extraSpacing : 0); + let charSpacing = baseCharSpacing + (i + 1 === ii ? extraSpacing : 0); let glyphWidth = glyph.width; if (font.vertical) { diff --git a/src/core/fonts.js b/src/core/fonts.js index 3e37fdd42..452490926 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3407,7 +3407,7 @@ class Font { if (typeof width !== "number") { width = this.defaultWidth; } - const vmetric = this.vmetrics?.[widthCode]; + const vmetric = this.vmetrics?.[widthCode] || this.defaultVMetrics; let unicode = this.toUnicode.get(charcode) || charcode; if (typeof unicode === "number") { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 54eecbe68..1870764b4 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -889,3 +889,4 @@ !mesh_shading_empty.pdf !acroform_calculation_order.pdf !extractPages_null_in_array.pdf +!issue20930.pdf diff --git a/test/pdfs/issue20930.pdf b/test/pdfs/issue20930.pdf new file mode 100644 index 000000000..9bd7c12f3 Binary files /dev/null and b/test/pdfs/issue20930.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 7dac82e9b..b4142a84f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -14005,5 +14005,12 @@ "md5": "5a1bf9cb73010d84b47d91bb66bae27d", "rounds": 1, "type": "eq" + }, + { + "id": "issue20930-text", + "file": "pdfs/issue20930.pdf", + "md5": "321f0901af604a6052baa7b2855a7e3e", + "rounds": 1, + "type": "text" } ]