Skip to content

Commit

Permalink
Fix invalid XUID entries in CFF fonts
Browse files Browse the repository at this point in the history
In CFF fonts, entry `XUID` should be an array that has no more than
16 elements. In the issue, the length is 20, which causes the fonts to fail.
See Appendix B, "Implementation Limits" in PostScript Language Reference Manual
https://web.archive.org/web/20170218093716/https://www.adobe.com/products/postscript/pdfs/PLRM.pdf
Actually entries `XUID` and `UniqueID` are obsolete altogether.
https://blogs.adobe.com/CCJKType/2016/06/no-more-xuid-arrays.html
  • Loading branch information
janpe2 committed Oct 5, 2020
1 parent b3e32e2 commit 935568c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/cff_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,12 @@ class CFFCompiler {
}
}

const xuid = cff.topDict.getByName("XUID");
if (xuid && xuid.length > 16) {
// Length of XUID array must not be greater than 16 (issue #12399).
cff.topDict.removeByName("XUID");
}

cff.topDict.setByName("charset", 0);
var compiled = this.compileTopDicts(
[cff.topDict],
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
!issue5202.pdf
!images_1bit_grayscale.pdf
!issue5280.pdf
!issue12399_reduced.pdf
!issue5677.pdf
!issue5954.pdf
!issue6612.pdf
Expand Down
Binary file added test/pdfs/issue12399_reduced.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,12 @@
"type": "eq",
"about": "Please note that this file currently renders incorrectly."
},
{ "id": "issue12399",
"file": "pdfs/issue12399_reduced.pdf",
"md5": "01bdd258be93e10f8399708eecedbfd6",
"rounds": 1,
"type": "eq"
},
{ "id": "issue5808-text",
"file": "pdfs/issue5808.pdf",
"md5": "e0584dd540d7859d6c191aa53379692e",
Expand Down

0 comments on commit 935568c

Please sign in to comment.