mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Make CMap.map quasi-private.
This makes it easier for the representation to be improved.
This commit is contained in:
parent
1e52c770d9
commit
b86daed29d
3 changed files with 44 additions and 30 deletions
|
@ -199,7 +199,7 @@ var CMap = (function CMapClosure() {
|
|||
// where nBytePairs are ranges e.g. [low1, high1, low2, high2, ...]
|
||||
this.codespaceRanges = [[], [], [], []];
|
||||
this.numCodespaceRanges = 0;
|
||||
this.map = [];
|
||||
this._map = [];
|
||||
this.vertical = false;
|
||||
this.useCMap = null;
|
||||
this.builtInCMap = builtInCMap;
|
||||
|
@ -213,7 +213,7 @@ var CMap = (function CMapClosure() {
|
|||
mapRange: function(low, high, dstLow) {
|
||||
var lastByte = dstLow.length - 1;
|
||||
while (low <= high) {
|
||||
this.map[low] = dstLow;
|
||||
this._map[low] = dstLow;
|
||||
// Only the last byte has to be incremented.
|
||||
dstLow = dstLow.substr(0, lastByte) +
|
||||
String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
|
||||
|
@ -224,17 +224,36 @@ var CMap = (function CMapClosure() {
|
|||
mapRangeToArray: function(low, high, array) {
|
||||
var i = 0, ii = array.length;
|
||||
while (low <= high && i < ii) {
|
||||
this.map[low] = array[i++];
|
||||
this._map[low] = array[i++];
|
||||
++low;
|
||||
}
|
||||
},
|
||||
|
||||
mapOne: function(src, dst) {
|
||||
this.map[src] = dst;
|
||||
this._map[src] = dst;
|
||||
},
|
||||
|
||||
lookup: function(code) {
|
||||
return this.map[code];
|
||||
return this._map[code];
|
||||
},
|
||||
|
||||
contains: function(code) {
|
||||
return this._map[code] !== undefined;
|
||||
},
|
||||
|
||||
forEach: function(callback) {
|
||||
var map = this._map;
|
||||
for (var key in this._map) {
|
||||
callback(key, map[key]);
|
||||
}
|
||||
},
|
||||
|
||||
charCodeOf: function(value) {
|
||||
return this._map.indexOf(value);
|
||||
},
|
||||
|
||||
getMap: function() {
|
||||
return this._map;
|
||||
},
|
||||
|
||||
readCharCode: function(str, offset) {
|
||||
|
@ -789,12 +808,11 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||
}
|
||||
// Merge the map into the current one, making sure not to override
|
||||
// any previously defined entries.
|
||||
for (var key in cMap.useCMap.map) {
|
||||
if (key in cMap.map) {
|
||||
continue;
|
||||
cMap.useCMap.forEach(function(key, value) {
|
||||
if (!cMap.contains(key)) {
|
||||
cMap.mapOne(key, cMap.useCMap.lookup(key));
|
||||
}
|
||||
cMap.map[key] = cMap.useCMap.map[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parseBinaryCMap(name, builtInCMapParams) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue