mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #2875 from vyv03354/tounicode
Convert CID fonts using "ToUnicode" CMap if available
This commit is contained in:
commit
4c061cdbf4
3 changed files with 22 additions and 6 deletions
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue