Merge pull request #20933 from calixteman/issue20930

Fix charSpacing in vertical mode
This commit is contained in:
Tim van der Meij 2026-03-21 13:56:05 +01:00 committed by GitHub
commit a90215da48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 4 deletions

View File

@ -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) {

View File

@ -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") {

View File

@ -889,3 +889,4 @@
!mesh_shading_empty.pdf
!acroform_calculation_order.pdf
!extractPages_null_in_array.pdf
!issue20930.pdf

BIN
test/pdfs/issue20930.pdf Normal file

Binary file not shown.

View File

@ -14005,5 +14005,12 @@
"md5": "5a1bf9cb73010d84b47d91bb66bae27d",
"rounds": 1,
"type": "eq"
},
{
"id": "issue20930-text",
"file": "pdfs/issue20930.pdf",
"md5": "321f0901af604a6052baa7b2855a7e3e",
"rounds": 1,
"type": "text"
}
]