1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Add Hankaku-Latin cid to Unicode mappings

This commit is contained in:
vyv03354 2013-01-30 02:46:17 +09:00
parent 7bd8887860
commit a8aed74431
4 changed files with 31 additions and 10 deletions

View file

@ -413,6 +413,19 @@ var CMapConverterList = {
'90msp-RKSJ-V': sjisToUnicode
};
// CMaps using Hankaku (Halfwidth) Latin glyphs instead of proportional one.
// We need to distinguish them to get correct widths from CIDFont dicts.
var HalfwidthCMaps = {
'H': true,
'V': true,
'EUC-H': true,
'EUC-V': true,
'90ms-RKSJ-H': true,
'90ms-RKSJ-V': true,
'UniJIS-UCS2-HW-H': true,
'UniJIS-UCS2-HW-V': true
};
var decodeBytes;
if (typeof TextDecoder !== 'undefined') {
decodeBytes = function(bytes, encoding) {
@ -4141,14 +4154,18 @@ 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) {
var unicode = cidToUnicode[i];
if (isArray(unicode)) {
var length = unicode.length;
for (j = 0; j < length; j++) {
cidToUnicodeMap[cid] = unicode[j];
unicodeToCIDMap[unicode[j]] = cid;
cidToUnicodeMap[cid] = k = unicode[j];
if (!unicodeToCIDMap[k] || overwrite) {
unicodeToCIDMap[k] = cid;
}
}
cid++;
} else if (typeof unicode === 'object') {
@ -4157,7 +4174,9 @@ var Font = (function FontClosure() {
k = unicode.c;
for (j = 0; j < fillLength; ++j) {
cidToUnicodeMap[cid] = k;
unicodeToCIDMap[k] = cid;
if (!unicodeToCIDMap[k] || overwrite) {
unicodeToCIDMap[k] = cid;
}
cid++;
k++;
}
@ -4165,13 +4184,14 @@ var Font = (function FontClosure() {
cid += unicode.s;
} else if (unicode) {
cidToUnicodeMap[cid] = unicode;
unicodeToCIDMap[unicode] = cid;
if (!unicodeToCIDMap[unicode] || overwrite) {
unicodeToCIDMap[unicode] = cid;
}
cid++;
} else
cid++;
}
var cidEncoding = properties.cidEncoding;
if (!cidEncoding) {
return;
}