1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 06:38:07 +02:00

Merge pull request #18253 from calixteman/bug1539074

Compute correctly the unitsPerEm value from the fontMatrix when converting a font (bug 1539074)
This commit is contained in:
calixteman 2024-06-16 12:17:10 +02:00 committed by GitHub
commit f8acd33527
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 2 deletions

View file

@ -798,7 +798,9 @@ function createOS2Table(properties, charstrings, override) {
const bbox = properties.bbox || [0, 0, 0, 0]; const bbox = properties.bbox || [0, 0, 0, 0];
const unitsPerEm = const unitsPerEm =
override.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 // if the font units differ to the PDF glyph space units
// then scale up the values // then scale up the values
@ -3196,7 +3198,9 @@ class Font {
properties.seacMap = seacMap; 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"); const builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F");
// PostScript Font Program // PostScript Font Program

View file

@ -649,3 +649,4 @@
!tracemonkey_freetext.pdf !tracemonkey_freetext.pdf
!issue17998.pdf !issue17998.pdf
!pdfjs_wikipedia.pdf !pdfjs_wikipedia.pdf
!bug1539074.pdf

BIN
test/pdfs/bug1539074.pdf Executable file

Binary file not shown.

View file

@ -10081,5 +10081,12 @@
"rounds": 1, "rounds": 1,
"link": true, "link": true,
"type": "eq" "type": "eq"
},
{
"id": "bug1539074",
"file": "pdfs/bug1539074.pdf",
"md5": "73922be020083d54747af18a4d5e0768",
"rounds": 1,
"type": "eq"
} }
] ]