Skip to content

Commit

Permalink
Merge pull request #18253 from calixteman/bug1539074
Browse files Browse the repository at this point in the history
Compute correctly the unitsPerEm value from the fontMatrix when converting a font (bug 1539074)
  • Loading branch information
calixteman authored Jun 16, 2024
2 parents 2effc96 + d145220 commit f8acd33
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,4 @@
!tracemonkey_freetext.pdf
!issue17998.pdf
!pdfjs_wikipedia.pdf
!bug1539074.pdf
Binary file added test/pdfs/bug1539074.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 @@ -10081,5 +10081,12 @@
"rounds": 1,
"link": true,
"type": "eq"
},
{
"id": "bug1539074",
"file": "pdfs/bug1539074.pdf",
"md5": "73922be020083d54747af18a4d5e0768",
"rounds": 1,
"type": "eq"
}
]

0 comments on commit f8acd33

Please sign in to comment.