Skip to content

Commit 5631e5b

Browse files
committed
Merge pull request mozilla#2562 from vyv03354/master
Fix a problem about Japanese PDFs without embedded fonts
2 parents d111003 + bff75fa commit 5631e5b

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

src/evaluator.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
791791
};
792792
}
793793

794+
var cidEncoding = baseDict.get('Encoding');
795+
if (isName(cidEncoding))
796+
properties.cidEncoding = cidEncoding.name;
797+
794798
var cidToGidMap = dict.get('CIDToGIDMap');
795799
if (isStream(cidToGidMap))
796800
properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);

src/fonts.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4126,6 +4126,15 @@ var Font = (function FontClosure() {
41264126
} else
41274127
cid++;
41284128
}
4129+
4130+
var cidEncoding = properties.cidEncoding;
4131+
if (cidEncoding && cidEncoding.indexOf('Uni') === 0) {
4132+
// input is already Unicode for Uni* CMap encodings.
4133+
// However, Unicode-to-CID conversion is needed
4134+
// regardless of the CMap encoding. So we can't reset
4135+
// unicodeToCID.
4136+
this.cidToUnicode = [];
4137+
}
41294138
},
41304139

41314140
bindDOM: function Font_bindDOM() {
@@ -4205,16 +4214,12 @@ var Font = (function FontClosure() {
42054214
case 'CIDFontType0':
42064215
if (this.noUnicodeAdaptation) {
42074216
width = this.widths[this.unicodeToCID[charcode] || charcode];
4208-
fontCharCode = mapPrivateUseChars(charcode);
4209-
break;
42104217
}
42114218
fontCharCode = this.toFontChar[charcode] || charcode;
42124219
break;
42134220
case 'CIDFontType2':
42144221
if (this.noUnicodeAdaptation) {
42154222
width = this.widths[this.unicodeToCID[charcode] || charcode];
4216-
fontCharCode = mapPrivateUseChars(charcode);
4217-
break;
42184223
}
42194224
fontCharCode = this.toFontChar[charcode] || charcode;
42204225
break;

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737
!basicapi.pdf
3838
!mixedfonts.pdf
3939
!shading_extend.pdf
40+
!noembed-identity.pdf

test/pdfs/noembed-identity.pdf

2.98 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,5 +795,11 @@
795795
"md5": "9f11e815b485f7f0e1fa5c116c636cf9",
796796
"rounds": 1,
797797
"type": "eq"
798+
},
799+
{ "id": "noembed-identity",
800+
"file": "pdfs/noembed-identity.pdf",
801+
"md5": "05d3803b6c22451e18cb60d8d8c75c0c",
802+
"rounds": 1,
803+
"type": "eq"
798804
}
799805
]

0 commit comments

Comments
 (0)