Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair CFF fonts if stem hints are in wrong order #10277

Merged
merged 1 commit into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/core/cff_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,16 @@ var CFFParser = (function CFFParserClosure() {
if (validationCommand) {
if (validationCommand.stem) {
state.hints += stackSize >> 1;
if (value === 3 || value === 23) {
// vstem or vstemhm.
state.hasVStems = true;
} else if (state.hasVStems && (value === 1 || value === 18)) {
// Some browsers don't draw glyphs that specify vstems before
// hstems. As a workaround, replace hstem (1) and hstemhm (18)
// with a pointless vstem (3) or vstemhm (23).
warn('CFF stem hints are in wrong order');
data[j - 1] = (value === 1) ? 3 : 23;
}
}
if ('min' in validationCommand) {
if (!state.undefStack && stackSize < validationCommand.min) {
Expand Down Expand Up @@ -599,6 +609,7 @@ var CFFParser = (function CFFParserClosure() {
firstStackClearing: true,
seac: null,
width: null,
hasVStems: false,
};
var valid = true;
var localSubrToUse = null;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
!annotation-tx3.pdf
!coons-allflags-withfunction.pdf
!tensor-allflags-withfunction.pdf
!issue10084_reduced.pdf
!issue4246.pdf
!issue4461.pdf
!issue4573.pdf
Expand Down
Binary file added test/pdfs/issue10084_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 @@ -2750,6 +2750,12 @@
"type": "text",
"about": "Note that the text layer seems to be off to the right."
},
{ "id": "issue10084",
"file": "pdfs/issue10084_reduced.pdf",
"md5": "ae37cf36f2e319688c608e4086836824",
"rounds": 1,
"type": "eq"
},
{ "id": "issue4890",
"file": "pdfs/issue4890.pdf",
"md5": "1666feb4cd26318c2bdbea6a175dce87",
Expand Down