Replace command with not enough args by an endchar in CFF font

- Right now, a glyph with an erroneous outline is replaced by an empty glyph
    if the error is far enough from the start there's likely something to render
    so the idea is to replace a command with args by an endchar when no args are
    on the stack: this way OTS is likely happy (no remaining args on stack) and we
    can draw something which is likely better than nothing.
This commit is contained in:
Calixte Denizet 2021-05-14 13:38:26 +02:00
parent e394da5861
commit 1a2cea21a5
4 changed files with 15 additions and 0 deletions

View File

@ -626,6 +626,14 @@ const CFFParser = (function CFFParserClosure() {
", expected: " +
validationCommand.min
);
if (stackSize === 0) {
// Just "fix" the outline in replacing command by a endchar:
// it could lead to wrong rendering of some glyphs or not.
// For example, the pdf in #6132 is well-rendered.
data[j - 1] = 14;
return true;
}
return false;
}
}

View File

@ -129,6 +129,7 @@
!bug1513120_reduced.pdf
!bug1538111.pdf
!bug1552113.pdf
!issue6132.pdf
!issue9949.pdf
!bug1308536.pdf
!bug1337429.pdf

BIN
test/pdfs/issue6132.pdf Normal file

Binary file not shown.

View File

@ -2616,6 +2616,12 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue6132",
"file": "pdfs/issue6132.pdf",
"md5": "bd1e6252ca642acf2cd05db1748a073c",
"rounds": 1,
"type": "eq"
},
{ "id": "issue4875",
"file": "pdfs/issue4875.pdf",
"md5": "9a558e18029a42c0ef4e9a8755e24733",