Skip to content

Commit a90215d

Browse files
Merge pull request #20933 from calixteman/issue20930
Fix charSpacing in vertical mode
2 parents d666293 + eaa5eca commit a90215d

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/core/evaluator.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,9 +2948,12 @@ class PartialEvaluator {
29482948
}
29492949

29502950
const font = textState.font;
2951+
const baseCharSpacing = font.vertical
2952+
? -textState.charSpacing
2953+
: textState.charSpacing;
29512954
if (!chars) {
29522955
// Just move according to the space we have.
2953-
const charSpacing = textState.charSpacing + extraSpacing;
2956+
const charSpacing = baseCharSpacing + extraSpacing;
29542957
if (charSpacing) {
29552958
if (!font.vertical) {
29562959
textState.translateTextMatrix(
@@ -2979,8 +2982,7 @@ class PartialEvaluator {
29792982
if (category.isInvisibleFormatMark) {
29802983
continue;
29812984
}
2982-
let charSpacing =
2983-
textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
2985+
let charSpacing = baseCharSpacing + (i + 1 === ii ? extraSpacing : 0);
29842986

29852987
let glyphWidth = glyph.width;
29862988
if (font.vertical) {

src/core/fonts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,7 @@ class Font {
34073407
if (typeof width !== "number") {
34083408
width = this.defaultWidth;
34093409
}
3410-
const vmetric = this.vmetrics?.[widthCode];
3410+
const vmetric = this.vmetrics?.[widthCode] || this.defaultVMetrics;
34113411

34123412
let unicode = this.toUnicode.get(charcode) || charcode;
34133413
if (typeof unicode === "number") {

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,3 +889,4 @@
889889
!mesh_shading_empty.pdf
890890
!acroform_calculation_order.pdf
891891
!extractPages_null_in_array.pdf
892+
!issue20930.pdf

test/pdfs/issue20930.pdf

138 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14005,5 +14005,12 @@
1400514005
"md5": "5a1bf9cb73010d84b47d91bb66bae27d",
1400614006
"rounds": 1,
1400714007
"type": "eq"
14008+
},
14009+
{
14010+
"id": "issue20930-text",
14011+
"file": "pdfs/issue20930.pdf",
14012+
"md5": "321f0901af604a6052baa7b2855a7e3e",
14013+
"rounds": 1,
14014+
"type": "text"
1400814015
}
1400914016
]

0 commit comments

Comments
 (0)