Skip to content

Commit

Permalink
Fix the computation of unitsPerEm when the fontMatrix has some negati…
Browse files Browse the repository at this point in the history
…ve coefficients

It's a follow-up of mozilla#18253.
  • Loading branch information
calixteman committed Jun 24, 2024
1 parent 6784124 commit 42bb2b0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ function createOS2Table(properties, charstrings, override) {
const unitsPerEm =
override.unitsPerEm ||
(properties.fontMatrix
? 1 / Math.max(...properties.fontMatrix.slice(0, 4))
? 1 / Math.max(...properties.fontMatrix.slice(0, 4).map(Math.abs))
: 1000);

// if the font units differ to the PDF glyph space units
Expand Down Expand Up @@ -3199,7 +3199,7 @@ class Font {
}

const unitsPerEm = properties.fontMatrix
? 1 / Math.max(...properties.fontMatrix.slice(0, 4))
? 1 / Math.max(...properties.fontMatrix.slice(0, 4).map(Math.abs))
: 1000;

const builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F");
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,4 @@
!issue17998.pdf
!pdfjs_wikipedia.pdf
!bug1539074.pdf
!bug1539074.1.pdf
Binary file added test/pdfs/bug1539074.1.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10098,6 +10098,13 @@
"rounds": 1,
"type": "eq"
},
{
"id": "bug1539074_1",
"file": "pdfs/bug1539074.1.pdf",
"md5": "d15c49142fda433323d3d35f2762cd33",
"rounds": 1,
"type": "eq"
},
{
"id": "bug1903731",
"file": "pdfs/bug1903731.pdf",
Expand Down

0 comments on commit 42bb2b0

Please sign in to comment.