Enhance the converter code by filling Format 6 dense array gaps
This commit is contained in:
parent
e9ed96d97c
commit
4f7fb7539b
31
fonts.js
31
fonts.js
@ -427,18 +427,39 @@ var Font = (function () {
|
|||||||
var firstCode = FontsUtils.bytesToInteger(font.getBytes(2));
|
var firstCode = FontsUtils.bytesToInteger(font.getBytes(2));
|
||||||
var entryCount = FontsUtils.bytesToInteger(font.getBytes(2));
|
var entryCount = FontsUtils.bytesToInteger(font.getBytes(2));
|
||||||
|
|
||||||
|
// Since Format 6 is a dense array, check for gaps in the indexes
|
||||||
|
// to fill them later if needed
|
||||||
|
var gaps = [];
|
||||||
|
for (var j = 1; j <= entryCount; j++)
|
||||||
|
gaps.push(j);
|
||||||
|
|
||||||
var encoding = properties.encoding;
|
var encoding = properties.encoding;
|
||||||
var glyphs = [];
|
var glyphs = [];
|
||||||
for (var j = 0; j < entryCount; j++) {
|
for (var j = 0; j < entryCount; j++) {
|
||||||
var charcode = FontsUtils.bytesToInteger(font.getBytes(2));
|
var charcode = FontsUtils.bytesToInteger(font.getBytes(2));
|
||||||
glyphs.push({unicode: charcode + firstCode });
|
var index = gaps.indexOf(charcode);
|
||||||
|
if (index != -1)
|
||||||
|
gaps.splice(index, 1);
|
||||||
|
|
||||||
|
glyphs.push({unicode: charcode + firstCode});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (gaps.length)
|
||||||
|
glyphs.push({unicode: gaps.pop() + firstCode });
|
||||||
|
|
||||||
var ranges = getRanges(glyphs);
|
var ranges = getRanges(glyphs);
|
||||||
var denseRange = ranges[0];
|
|
||||||
var pos = 0;
|
var pos = firstCode;
|
||||||
for (var j = denseRange[0]; j <= denseRange[1]; j++)
|
var bias = 1;
|
||||||
encoding[j - 1] = glyphs[pos++].unicode;
|
for (var j = 0; j < ranges.length; j++) {
|
||||||
|
var range = ranges[j];
|
||||||
|
var start = range[0];
|
||||||
|
var end = range[1];
|
||||||
|
for (var k = start; k < end; k++) {
|
||||||
|
encoding[pos] = glyphs[pos - firstCode].unicode;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
cmap.data = createCMapTable(glyphs);
|
cmap.data = createCMapTable(glyphs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
pdf.js
2
pdf.js
@ -2234,7 +2234,7 @@ var CanvasGraphics = (function() {
|
|||||||
// The encoding mapping table will be filled
|
// The encoding mapping table will be filled
|
||||||
// later during the building phase
|
// later during the building phase
|
||||||
//encodingMap[k] = GlyphsUnicode[encoding[code]];
|
//encodingMap[k] = GlyphsUnicode[encoding[code]];
|
||||||
charset.push(encoding[code++]);
|
charset.push(encoding[code++] || ".notdef");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user