Add support for beginfbchar
This commit is contained in:
parent
aea63a7051
commit
42653edf9a
38
fonts.js
38
fonts.js
@ -816,6 +816,8 @@ var Font = (function Font() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var encoding = properties.encoding;
|
||||||
|
var charset = properties.charset;
|
||||||
for (var i = 0; i < numRecords; i++) {
|
for (var i = 0; i < numRecords; i++) {
|
||||||
var table = records[i];
|
var table = records[i];
|
||||||
font.pos = start + table.offset;
|
font.pos = start + table.offset;
|
||||||
@ -824,38 +826,41 @@ var Font = (function Font() {
|
|||||||
var length = int16(font.getBytes(2));
|
var length = int16(font.getBytes(2));
|
||||||
var language = int16(font.getBytes(2));
|
var language = int16(font.getBytes(2));
|
||||||
|
|
||||||
if (format == 0 && numRecords > 1) {
|
if (format == 0) {
|
||||||
// Characters below 0x20 are controls characters that are hardcoded
|
// Characters below 0x20 are controls characters that are hardcoded
|
||||||
// into the platform so if some characters in the font are assigned
|
// into the platform so if some characters in the font are assigned
|
||||||
// under this limit they will not be displayed so let's rewrite the
|
// under this limit they will not be displayed so let's rewrite the
|
||||||
// CMap.
|
// CMap.
|
||||||
var map = [];
|
var glyphs = [];
|
||||||
var rewrite = false;
|
if (encoding.empty) {
|
||||||
for (var j = 0; j < 256; j++) {
|
var orderedGlyphs= [];
|
||||||
var index = font.getByte();
|
for ( var j = 0; j < charset.length; j++) {
|
||||||
if (index != 0) {
|
var unicode = GlyphsUnicode[charset[font.getByte()]] || 0;
|
||||||
map.push(index);
|
glyphs.push({ unicode: unicode });
|
||||||
if (j < 0x20)
|
orderedGlyphs.push(unicode);
|
||||||
rewrite = true;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (rewrite) {
|
orderedGlyphs.sort(function(a, b) {
|
||||||
var glyphs = [];
|
return a - b;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var p in encoding) {
|
||||||
|
if (p != "empty")
|
||||||
|
properties.encoding[p] = orderedGlyphs[p - 1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (var j = 0x20; j < 256; j++) {
|
for (var j = 0x20; j < 256; j++) {
|
||||||
// TODO do not hardcode WinAnsiEncoding
|
// TODO do not hardcode WinAnsiEncoding
|
||||||
var unicode = GlyphsUnicode[Encodings["WinAnsiEncoding"][j]];
|
var unicode = GlyphsUnicode[Encodings["WinAnsiEncoding"][j]];
|
||||||
glyphs.push({ unicode: unicode });
|
glyphs.push({ unicode: unicode });
|
||||||
}
|
}
|
||||||
cmap.data = createCMapTable(glyphs);
|
|
||||||
}
|
}
|
||||||
} else if ((format == 0 && numRecords == 1) ||
|
cmap.data = createCMapTable(glyphs);
|
||||||
(format == 6 && numRecords == 1 && !properties.encoding.empty)) {
|
} else if (format == 6 && numRecords == 1 && !encoding.empty) {
|
||||||
// Format 0 alone is not allowed by the sanitizer so let's rewrite
|
// Format 0 alone is not allowed by the sanitizer so let's rewrite
|
||||||
// that to a 3-1-4 Unicode BMP table
|
// that to a 3-1-4 Unicode BMP table
|
||||||
TODO('Use an other source of informations than ' +
|
TODO('Use an other source of informations than ' +
|
||||||
'charset here, it is not reliable');
|
'charset here, it is not reliable');
|
||||||
var charset = properties.charset;
|
|
||||||
var glyphs = [];
|
var glyphs = [];
|
||||||
for (var j = 0; j < charset.length; j++) {
|
for (var j = 0; j < charset.length; j++) {
|
||||||
glyphs.push({
|
glyphs.push({
|
||||||
@ -898,7 +903,6 @@ var Font = (function Font() {
|
|||||||
assert(ranges.length == 1, 'Got ' + ranges.length +
|
assert(ranges.length == 1, 'Got ' + ranges.length +
|
||||||
' ranges in a dense array');
|
' ranges in a dense array');
|
||||||
|
|
||||||
var encoding = properties.encoding;
|
|
||||||
var denseRange = ranges[0];
|
var denseRange = ranges[0];
|
||||||
var start = denseRange[0];
|
var start = denseRange[0];
|
||||||
var end = denseRange[1];
|
var end = denseRange[1];
|
||||||
|
14
pdf.js
14
pdf.js
@ -3763,6 +3763,7 @@ var PartialEvaluator = (function() {
|
|||||||
error('useCMap is not implemented');
|
error('useCMap is not implemented');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'beginbfchar':
|
||||||
case 'beginbfrange':
|
case 'beginbfrange':
|
||||||
case 'begincodespacerange':
|
case 'begincodespacerange':
|
||||||
token = '';
|
token = '';
|
||||||
@ -3780,17 +3781,18 @@ var PartialEvaluator = (function() {
|
|||||||
var code = parseInt('0x' + tokens[j + 2]);
|
var code = parseInt('0x' + tokens[j + 2]);
|
||||||
|
|
||||||
for (var k = startRange; k <= endRange; k++) {
|
for (var k = startRange; k <= endRange; k++) {
|
||||||
// The encoding mapping table will be filled
|
|
||||||
// later during the building phase
|
|
||||||
//encodingMap[k] = GlyphsUnicode[encoding[code]];
|
|
||||||
charset.push(encoding[code++] || '.notdef');
|
charset.push(encoding[code++] || '.notdef');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'beginfbchar':
|
case 'endbfchar':
|
||||||
case 'endfbchar':
|
for (var j = 0; j < tokens.length; j += 2) {
|
||||||
error('fbchar parsing is not implemented');
|
var index = parseInt('0x' + tokens[j]);
|
||||||
|
var code = parseInt('0x' + tokens[j + 1]);
|
||||||
|
encodingMap[index] = GlyphsUnicode[encoding[code]];
|
||||||
|
charset.push(encoding[code] || '.notdef');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user