Skip to content

Commit efc5c3c

Browse files
authored
Merge pull request #19862 from calixteman/bug1961423
Fix 'print to pdf' on Mac with a cid font (bug 1961423)
2 parents 312c85b + 785991a commit efc5c3c

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/core/cff_parser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,12 +1769,16 @@ class CFFCompiler {
17691769
if (isCIDFont) {
17701770
// In a CID font, the charset is a mapping of CIDs not SIDs so just
17711771
// create an identity mapping.
1772+
// nLeft: Glyphs left in range (excluding first) (see the CFF specs).
1773+
// Having a wrong value for nLeft induces a print issue on MacOS (see
1774+
// https://bugzilla.mozilla.org/1961423).
1775+
const nLeft = numGlyphsLessNotDef - 1;
17721776
out = new Uint8Array([
17731777
2, // format
17741778
0, // first CID upper byte
17751779
0, // first CID lower byte
1776-
(numGlyphsLessNotDef >> 8) & 0xff,
1777-
numGlyphsLessNotDef & 0xff,
1780+
(nLeft >> 8) & 0xff,
1781+
nLeft & 0xff,
17781782
]);
17791783
} else {
17801784
const length = 1 + numGlyphsLessNotDef * 2;

test/unit/cff_parser_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ describe("CFFCompiler", function () {
481481
0, // cid (high)
482482
0, // cid (low)
483483
0, // nLeft (high)
484-
numGlyphs - 1, // nLeft (low)
484+
numGlyphs - 2, // nLeft (low)
485485
]);
486486
});
487487

0 commit comments

Comments
 (0)