Convert CID fonts using "ToUnicode" CMap if available
This commit is contained in:
parent
32938d3a66
commit
6c3d66fb46
19
src/fonts.js
19
src/fonts.js
@ -2401,7 +2401,7 @@ var Font = (function FontClosure() {
|
||||
this.defaultVMetrics = properties.defaultVMetrics;
|
||||
}
|
||||
|
||||
if (properties.toUnicode)
|
||||
if (properties.toUnicode && properties.toUnicode.length > 0)
|
||||
this.toUnicode = properties.toUnicode;
|
||||
else
|
||||
this.rebuildToUnicode(properties);
|
||||
@ -4331,12 +4331,12 @@ var Font = (function FontClosure() {
|
||||
rebuildToUnicode: function Font_rebuildToUnicode(properties) {
|
||||
var firstChar = properties.firstChar, lastChar = properties.lastChar;
|
||||
var map = [];
|
||||
if (properties.composite) {
|
||||
var isIdentityMap = this.cidToUnicode.length === 0;
|
||||
var toUnicode = this.toUnicode || this.cidToUnicode;
|
||||
if (toUnicode) {
|
||||
var isIdentityMap = toUnicode.length === 0;
|
||||
for (var i = firstChar, ii = lastChar; i <= ii; i++) {
|
||||
// TODO missing map the character according font's CMap
|
||||
var cid = i;
|
||||
map[i] = isIdentityMap ? cid : this.cidToUnicode[cid];
|
||||
map[i] = isIdentityMap ? i : toUnicode[i];
|
||||
}
|
||||
} else {
|
||||
for (var i = firstChar, ii = lastChar; i <= ii; i++) {
|
||||
@ -4358,6 +4358,14 @@ var Font = (function FontClosure() {
|
||||
this.cidToUnicode = cidToUnicodeMap;
|
||||
this.unicodeToCID = unicodeToCIDMap;
|
||||
|
||||
var cidEncoding = properties.cidEncoding;
|
||||
if (properties.toUnicode) {
|
||||
if (cidEncoding && cidEncoding.indexOf('Identity-') !== 0) {
|
||||
TODO('Need to create a reverse mapping from \'ToUnicode\' CMap');
|
||||
}
|
||||
return; // 'ToUnicode' CMap will be used
|
||||
}
|
||||
|
||||
var cidSystemInfo = properties.cidSystemInfo;
|
||||
var cidToUnicode;
|
||||
if (cidSystemInfo) {
|
||||
@ -4368,7 +4376,6 @@ var Font = (function FontClosure() {
|
||||
if (!cidToUnicode)
|
||||
return; // identity encoding
|
||||
|
||||
var cidEncoding = properties.cidEncoding;
|
||||
var overwrite = HalfwidthCMaps[cidEncoding];
|
||||
var cid = 1, i, j, k, ii;
|
||||
for (i = 0, ii = cidToUnicode.length; i < ii; ++i) {
|
||||
|
1
test/pdfs/javauninstall-7.pdf.link
Normal file
1
test/pdfs/javauninstall-7.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
http://www.cyberagentfx.jp/gaikaex/pdf/javauninstall-7.pdf
|
@ -891,6 +891,14 @@
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "javauninstall-7",
|
||||
"file": "pdfs/javauninstall-7.pdf",
|
||||
"md5": "c9eb59503923c9125b9660e348618675",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"lastPage": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "jst2007-5",
|
||||
"file": "pdfs/JST2007-5.pdf",
|
||||
"md5": "9efa6c37fc771b36a60535036d1910bb",
|
||||
|
Loading…
Reference in New Issue
Block a user