Skip to content

Commit

Permalink
Merge pull request #7628 from Snuffleupagus/issue-7580
Browse files Browse the repository at this point in the history
Fallback to the `StandardEncoding` for Nonsymbolic fonts without `/Encoding` entry (issue 7580)
  • Loading branch information
Snuffleupagus authored Nov 29, 2016
2 parents 013f69e + 356b321 commit 451956c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,11 +1746,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (baseEncodingName) {
properties.defaultEncoding = getEncoding(baseEncodingName).slice();
} else {
encoding = (properties.type === 'TrueType' ?
WinAnsiEncoding : StandardEncoding);
var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
// According to "Table 114" in section "9.6.6.1 General" (under
// "9.6.6 Character Encoding") of the PDF specification, a Nonsymbolic
// font should use the `StandardEncoding` if no encoding is specified.
encoding = StandardEncoding;
if (properties.type === 'TrueType' && !isNonsymbolicFont) {
encoding = WinAnsiEncoding;
}
// The Symbolic attribute can be misused for regular fonts
// Heuristic: we have to check if the font is a standard one also
if (!!(properties.flags & FontFlags.Symbolic)) {
if (isSymbolicFont) {
encoding = MacRomanEncoding;
if (!properties.file) {
if (/Symbol/i.test(properties.name)) {
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
!issue7446.pdf
!issue7492.pdf
!issue7544.pdf
!issue7580.pdf
!issue7598.pdf
!issue7665.pdf
!issue7835.pdf
Expand Down
Binary file added test/pdfs/issue7580.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,20 @@
"link": false,
"type": "eq"
},
{ "id": "issue7580-eq",
"file": "pdfs/issue7580.pdf",
"md5": "44dd5a9b4373fcab9890cf567722a766",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue7580-text",
"file": "pdfs/issue7580.pdf",
"md5": "44dd5a9b4373fcab9890cf567722a766",
"rounds": 1,
"link": false,
"type": "text"
},
{ "id": "issue6612-text",
"file": "pdfs/issue6612.pdf",
"md5": "657f33236496916597cd70ef1222509a",
Expand Down

0 comments on commit 451956c

Please sign in to comment.