Fix lying sfnt header for some CFF font that pretend to be TrueType and fix unknown unicode glyphs when building from Type1
This commit is contained in:
parent
c6e4dadf94
commit
9ce69f94a6
12
fonts.js
12
fonts.js
@ -822,7 +822,7 @@ var Font = (function Font() {
|
|||||||
|
|
||||||
function readOpenTypeHeader(ttf) {
|
function readOpenTypeHeader(ttf) {
|
||||||
return {
|
return {
|
||||||
version: ttf.getBytes(4),
|
version: arrayToString(ttf.getBytes(4)),
|
||||||
numTables: int16(ttf.getBytes(2)),
|
numTables: int16(ttf.getBytes(2)),
|
||||||
searchRange: int16(ttf.getBytes(2)),
|
searchRange: int16(ttf.getBytes(2)),
|
||||||
entrySelector: int16(ttf.getBytes(2)),
|
entrySelector: int16(ttf.getBytes(2)),
|
||||||
@ -983,7 +983,7 @@ var Font = (function Font() {
|
|||||||
|
|
||||||
// The new numbers of tables will be the last one plus the num
|
// The new numbers of tables will be the last one plus the num
|
||||||
// of missing tables
|
// of missing tables
|
||||||
createOpenTypeHeader('\x00\x01\x00\x00', ttf, numTables);
|
createOpenTypeHeader(header.version, ttf, numTables);
|
||||||
|
|
||||||
if (requiredTables.indexOf('OS/2') != -1) {
|
if (requiredTables.indexOf('OS/2') != -1) {
|
||||||
tables.push({
|
tables.push({
|
||||||
@ -1829,7 +1829,7 @@ var CFF = function(name, file, properties) {
|
|||||||
for (var info in data.properties)
|
for (var info in data.properties)
|
||||||
properties[info] = data.properties[info];
|
properties[info] = data.properties[info];
|
||||||
|
|
||||||
var charstrings = this.getOrderedCharStrings(data.charstrings);
|
var charstrings = this.getOrderedCharStrings(data.charstrings, properties);
|
||||||
var type2Charstrings = this.getType2Charstrings(charstrings);
|
var type2Charstrings = this.getType2Charstrings(charstrings);
|
||||||
var subrs = this.getType2Subrs(data.subrs);
|
var subrs = this.getType2Subrs(data.subrs);
|
||||||
|
|
||||||
@ -1893,14 +1893,14 @@ CFF.prototype = {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
getOrderedCharStrings: function cff_getOrderedCharStrings(glyphs) {
|
getOrderedCharStrings: function cff_getOrderedCharStrings(glyphs, properties) {
|
||||||
var charstrings = [];
|
var charstrings = [];
|
||||||
var missings = [];
|
var missings = [];
|
||||||
|
|
||||||
for (var i = 0; i < glyphs.length; i++) {
|
for (var i = 0; i < glyphs.length; i++) {
|
||||||
var glyph = glyphs[i];
|
var glyph = glyphs[i];
|
||||||
var unicode = GlyphsUnicode[glyph.glyph];
|
var unicode = properties.glyphs[glyph.glyph];
|
||||||
if (!unicode) {
|
if ('undefined' == typeof(unicode)) {
|
||||||
if (glyph.glyph != '.notdef')
|
if (glyph.glyph != '.notdef')
|
||||||
missings.push(glyph.glyph);
|
missings.push(glyph.glyph);
|
||||||
} else {
|
} else {
|
||||||
|
9
pdf.js
9
pdf.js
@ -4392,7 +4392,9 @@ var PartialEvaluator = (function() {
|
|||||||
|
|
||||||
var descriptor = xref.fetch(fd);
|
var descriptor = xref.fetch(fd);
|
||||||
|
|
||||||
var fontName = xref.fetchIfRef(descriptor.get('FontName'));
|
var fontName = fontDict.get('Name');
|
||||||
|
if (!fontName)
|
||||||
|
fontName = xref.fetchIfRef(descriptor.get('FontName'));;
|
||||||
assertWellFormed(IsName(fontName), 'invalid font name');
|
assertWellFormed(IsName(fontName), 'invalid font name');
|
||||||
fontName = fontName.name.replace(/[\+,\-]/g, '_');
|
fontName = fontName.name.replace(/[\+,\-]/g, '_');
|
||||||
|
|
||||||
@ -4423,11 +4425,16 @@ var PartialEvaluator = (function() {
|
|||||||
glyphWidths[unicode++] = widths[i];
|
glyphWidths[unicode++] = widths[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var glyphsMap = {};
|
||||||
|
for (var p in glyphMap)
|
||||||
|
glyphsMap[glyphMap[p]] = encodingMap[p];
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
type: subType.name,
|
type: subType.name,
|
||||||
subtype: fileType,
|
subtype: fileType,
|
||||||
widths: glyphWidths,
|
widths: glyphWidths,
|
||||||
encoding: encodingMap,
|
encoding: encodingMap,
|
||||||
|
glyphs: glyphsMap,
|
||||||
builtInEncoding: builtInEncoding,
|
builtInEncoding: builtInEncoding,
|
||||||
charset: charset,
|
charset: charset,
|
||||||
firstChar: fontDict.get('FirstChar'),
|
firstChar: fontDict.get('FirstChar'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user