diff --git a/src/core/fonts.js b/src/core/fonts.js index 993d3340bfa94..7959f8ffc118d 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -798,7 +798,9 @@ function createOS2Table(properties, charstrings, override) { const bbox = properties.bbox || [0, 0, 0, 0]; const unitsPerEm = override.unitsPerEm || - 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0]; + (properties.fontMatrix + ? 1 / Math.max(...properties.fontMatrix.slice(0, 4)) + : 1000); // if the font units differ to the PDF glyph space units // then scale up the values @@ -3196,7 +3198,9 @@ class Font { properties.seacMap = seacMap; } - const unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0]; + const unitsPerEm = properties.fontMatrix + ? 1 / Math.max(...properties.fontMatrix.slice(0, 4)) + : 1000; const builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F"); // PostScript Font Program diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 733a26e08e12a..a0991c7193413 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -649,3 +649,4 @@ !tracemonkey_freetext.pdf !issue17998.pdf !pdfjs_wikipedia.pdf +!bug1539074.pdf diff --git a/test/pdfs/bug1539074.pdf b/test/pdfs/bug1539074.pdf new file mode 100755 index 0000000000000..a6ce4906b79b8 Binary files /dev/null and b/test/pdfs/bug1539074.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 07ca39da989fb..98eb53829e0f7 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -10081,5 +10081,12 @@ "rounds": 1, "link": true, "type": "eq" + }, + { + "id": "bug1539074", + "file": "pdfs/bug1539074.pdf", + "md5": "73922be020083d54747af18a4d5e0768", + "rounds": 1, + "type": "eq" } ]