|
@@ -14,58 +14,29 @@
|
|
*/
|
|
*/
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
-var sharedUtil = require('../shared/util.js');
|
|
|
|
-var corePrimitives = require('./primitives.js');
|
|
|
|
-var coreStream = require('./stream.js');
|
|
|
|
-var coreGlyphList = require('./glyphlist.js');
|
|
|
|
-var coreFontRenderer = require('./font_renderer.js');
|
|
|
|
-var coreEncodings = require('./encodings.js');
|
|
|
|
-var coreStandardFonts = require('./standard_fonts.js');
|
|
|
|
-var coreUnicode = require('./unicode.js');
|
|
|
|
-var coreType1Parser = require('./type1_parser.js');
|
|
|
|
-var coreCFFParser = require('./cff_parser.js');
|
|
|
|
-var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
|
|
|
-var FontType = sharedUtil.FontType;
|
|
|
|
-var assert = sharedUtil.assert;
|
|
|
|
-var bytesToString = sharedUtil.bytesToString;
|
|
|
|
-var error = sharedUtil.error;
|
|
|
|
-var info = sharedUtil.info;
|
|
|
|
-var isArray = sharedUtil.isArray;
|
|
|
|
-var isInt = sharedUtil.isInt;
|
|
|
|
-var isNum = sharedUtil.isNum;
|
|
|
|
-var readUint32 = sharedUtil.readUint32;
|
|
|
|
-var shadow = sharedUtil.shadow;
|
|
|
|
-var string32 = sharedUtil.string32;
|
|
|
|
-var warn = sharedUtil.warn;
|
|
|
|
-var MissingDataException = sharedUtil.MissingDataException;
|
|
|
|
-var isSpace = sharedUtil.isSpace;
|
|
|
|
-var Stream = coreStream.Stream;
|
|
|
|
-var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
|
|
|
|
-var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
|
|
|
|
-var FontRendererFactory = coreFontRenderer.FontRendererFactory;
|
|
|
|
-var StandardEncoding = coreEncodings.StandardEncoding;
|
|
|
|
-var MacRomanEncoding = coreEncodings.MacRomanEncoding;
|
|
|
|
-var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
|
|
|
|
-var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
|
|
|
|
-var getEncoding = coreEncodings.getEncoding;
|
|
|
|
-var getStdFontMap = coreStandardFonts.getStdFontMap;
|
|
|
|
-var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
|
|
|
|
-var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
|
|
|
|
-var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
|
|
|
|
-var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
|
|
|
|
-var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
|
|
|
|
-var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
|
|
|
|
-var Type1Parser = coreType1Parser.Type1Parser;
|
|
|
|
-var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
|
|
|
|
-var CFFParser = coreCFFParser.CFFParser;
|
|
|
|
-var CFFCompiler = coreCFFParser.CFFCompiler;
|
|
|
|
-var CFF = coreCFFParser.CFF;
|
|
|
|
-var CFFHeader = coreCFFParser.CFFHeader;
|
|
|
|
-var CFFTopDict = coreCFFParser.CFFTopDict;
|
|
|
|
-var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
|
|
|
|
-var CFFStrings = coreCFFParser.CFFStrings;
|
|
|
|
-var CFFIndex = coreCFFParser.CFFIndex;
|
|
|
|
-var CFFCharset = coreCFFParser.CFFCharset;
|
|
|
|
|
|
+Object.defineProperty(exports, "__esModule", {
|
|
|
|
+ value: true
|
|
|
|
+});
|
|
|
|
+exports.getFontType = exports.ProblematicCharRanges = exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.PRIVATE_USE_OFFSET_END = exports.PRIVATE_USE_OFFSET_START = exports.SEAC_ANALYSIS_ENABLED = undefined;
|
|
|
|
+
|
|
|
|
+var _util = require('../shared/util');
|
|
|
|
+
|
|
|
|
+var _cff_parser = require('./cff_parser');
|
|
|
|
+
|
|
|
|
+var _glyphlist = require('./glyphlist');
|
|
|
|
+
|
|
|
|
+var _encodings = require('./encodings');
|
|
|
|
+
|
|
|
|
+var _standard_fonts = require('./standard_fonts');
|
|
|
|
+
|
|
|
|
+var _unicode = require('./unicode');
|
|
|
|
+
|
|
|
|
+var _font_renderer = require('./font_renderer');
|
|
|
|
+
|
|
|
|
+var _stream = require('./stream');
|
|
|
|
+
|
|
|
|
+var _type1_parser = require('./type1_parser');
|
|
|
|
+
|
|
var PRIVATE_USE_OFFSET_START = 0xE000;
|
|
var PRIVATE_USE_OFFSET_START = 0xE000;
|
|
var PRIVATE_USE_OFFSET_END = 0xF8FF;
|
|
var PRIVATE_USE_OFFSET_END = 0xF8FF;
|
|
var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
|
|
var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
|
|
@@ -87,7 +58,7 @@ function adjustWidths(properties) {
|
|
if (!properties.fontMatrix) {
|
|
if (!properties.fontMatrix) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
|
|
|
|
|
|
+ if (properties.fontMatrix[0] === _util.FONT_IDENTITY_MATRIX[0]) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var scale = 0.001 / properties.fontMatrix[0];
|
|
var scale = 0.001 / properties.fontMatrix[0];
|
|
@@ -111,10 +82,10 @@ function adjustToUnicode(properties, builtInEncoding) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var toUnicode = [],
|
|
var toUnicode = [],
|
|
- glyphsUnicodeMap = getGlyphsUnicode();
|
|
|
|
|
|
+ glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
|
for (var charCode in builtInEncoding) {
|
|
for (var charCode in builtInEncoding) {
|
|
var glyphName = builtInEncoding[charCode];
|
|
var glyphName = builtInEncoding[charCode];
|
|
- var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
|
|
|
|
|
|
+ var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
|
|
if (unicode !== -1) {
|
|
if (unicode !== -1) {
|
|
toUnicode[charCode] = String.fromCharCode(unicode);
|
|
toUnicode[charCode] = String.fromCharCode(unicode);
|
|
}
|
|
}
|
|
@@ -124,28 +95,28 @@ function adjustToUnicode(properties, builtInEncoding) {
|
|
function getFontType(type, subtype) {
|
|
function getFontType(type, subtype) {
|
|
switch (type) {
|
|
switch (type) {
|
|
case 'Type1':
|
|
case 'Type1':
|
|
- return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
|
|
|
|
|
|
+ return subtype === 'Type1C' ? _util.FontType.TYPE1C : _util.FontType.TYPE1;
|
|
case 'CIDFontType0':
|
|
case 'CIDFontType0':
|
|
- return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
|
|
|
|
|
|
+ return subtype === 'CIDFontType0C' ? _util.FontType.CIDFONTTYPE0C : _util.FontType.CIDFONTTYPE0;
|
|
case 'OpenType':
|
|
case 'OpenType':
|
|
- return FontType.OPENTYPE;
|
|
|
|
|
|
+ return _util.FontType.OPENTYPE;
|
|
case 'TrueType':
|
|
case 'TrueType':
|
|
- return FontType.TRUETYPE;
|
|
|
|
|
|
+ return _util.FontType.TRUETYPE;
|
|
case 'CIDFontType2':
|
|
case 'CIDFontType2':
|
|
- return FontType.CIDFONTTYPE2;
|
|
|
|
|
|
+ return _util.FontType.CIDFONTTYPE2;
|
|
case 'MMType1':
|
|
case 'MMType1':
|
|
- return FontType.MMTYPE1;
|
|
|
|
|
|
+ return _util.FontType.MMTYPE1;
|
|
case 'Type0':
|
|
case 'Type0':
|
|
- return FontType.TYPE0;
|
|
|
|
|
|
+ return _util.FontType.TYPE0;
|
|
default:
|
|
default:
|
|
- return FontType.UNKNOWN;
|
|
|
|
|
|
+ return _util.FontType.UNKNOWN;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function recoverGlyphName(name, glyphsUnicodeMap) {
|
|
function recoverGlyphName(name, glyphsUnicodeMap) {
|
|
if (glyphsUnicodeMap[name] !== undefined) {
|
|
if (glyphsUnicodeMap[name] !== undefined) {
|
|
return name;
|
|
return name;
|
|
}
|
|
}
|
|
- var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
|
|
|
|
|
|
+ var unicode = (0, _unicode.getUnicodeForGlyph)(name, glyphsUnicodeMap);
|
|
if (unicode !== -1) {
|
|
if (unicode !== -1) {
|
|
for (var key in glyphsUnicodeMap) {
|
|
for (var key in glyphsUnicodeMap) {
|
|
if (glyphsUnicodeMap[key] === unicode) {
|
|
if (glyphsUnicodeMap[key] === unicode) {
|
|
@@ -153,7 +124,7 @@ function recoverGlyphName(name, glyphsUnicodeMap) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- info('Unable to recover a standard glyph name for: ' + name);
|
|
|
|
|
|
+ (0, _util.info)('Unable to recover a standard glyph name for: ' + name);
|
|
return name;
|
|
return name;
|
|
}
|
|
}
|
|
var Glyph = function GlyphClosure() {
|
|
var Glyph = function GlyphClosure() {
|
|
@@ -235,10 +206,10 @@ var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
|
|
return undefined;
|
|
return undefined;
|
|
},
|
|
},
|
|
charCodeOf: function charCodeOf(v) {
|
|
charCodeOf: function charCodeOf(v) {
|
|
- return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
|
|
|
|
|
|
+ return (0, _util.isInt)(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
|
|
},
|
|
},
|
|
amend: function amend(map) {
|
|
amend: function amend(map) {
|
|
- error('Should not call amend()');
|
|
|
|
|
|
+ (0, _util.error)('Should not call amend()');
|
|
}
|
|
}
|
|
};
|
|
};
|
|
return IdentityToUnicodeMap;
|
|
return IdentityToUnicodeMap;
|
|
@@ -310,7 +281,7 @@ var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
|
|
writeData(file, tableOffsets[i], table);
|
|
writeData(file, tableOffsets[i], table);
|
|
}
|
|
}
|
|
if (sfnt === 'true') {
|
|
if (sfnt === 'true') {
|
|
- sfnt = string32(0x00010000);
|
|
|
|
|
|
+ sfnt = (0, _util.string32)(0x00010000);
|
|
}
|
|
}
|
|
file[0] = sfnt.charCodeAt(0) & 0xFF;
|
|
file[0] = sfnt.charCodeAt(0) & 0xFF;
|
|
file[1] = sfnt.charCodeAt(1) & 0xFF;
|
|
file[1] = sfnt.charCodeAt(1) & 0xFF;
|
|
@@ -330,7 +301,7 @@ var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
|
|
file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
|
|
file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
|
|
var checksum = 0;
|
|
var checksum = 0;
|
|
for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
|
|
for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
|
|
- var quad = readUint32(file, j);
|
|
|
|
|
|
+ var quad = (0, _util.readUint32)(file, j);
|
|
checksum = checksum + quad >>> 0;
|
|
checksum = checksum + quad >>> 0;
|
|
}
|
|
}
|
|
writeInt32(file, offset + 4, checksum);
|
|
writeInt32(file, offset + 4, checksum);
|
|
@@ -384,7 +355,7 @@ var Font = function FontClosure() {
|
|
for (charCode = 0; charCode < 256; charCode++) {
|
|
for (charCode = 0; charCode < 256; charCode++) {
|
|
this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
|
|
this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
|
|
}
|
|
}
|
|
- this.fontType = FontType.TYPE3;
|
|
|
|
|
|
+ this.fontType = _util.FontType.TYPE3;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.cidEncoding = properties.cidEncoding;
|
|
this.cidEncoding = properties.cidEncoding;
|
|
@@ -396,12 +367,12 @@ var Font = function FontClosure() {
|
|
var glyphsUnicodeMap;
|
|
var glyphsUnicodeMap;
|
|
if (!file || file.isEmpty) {
|
|
if (!file || file.isEmpty) {
|
|
if (file) {
|
|
if (file) {
|
|
- warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
|
|
|
|
|
|
+ (0, _util.warn)('Font file is empty in "' + name + '" (' + this.loadedName + ')');
|
|
}
|
|
}
|
|
this.missingFile = true;
|
|
this.missingFile = true;
|
|
var fontName = name.replace(/[,_]/g, '-');
|
|
var fontName = name.replace(/[,_]/g, '-');
|
|
- var stdFontMap = getStdFontMap(),
|
|
|
|
- nonStdFontMap = getNonStdFontMap();
|
|
|
|
|
|
+ var stdFontMap = (0, _standard_fonts.getStdFontMap)(),
|
|
|
|
+ nonStdFontMap = (0, _standard_fonts.getNonStdFontMap)();
|
|
var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
|
|
var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
|
|
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
|
|
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
|
|
this.bold = fontName.search(/bold/gi) !== -1;
|
|
this.bold = fontName.search(/bold/gi) !== -1;
|
|
@@ -409,13 +380,13 @@ var Font = function FontClosure() {
|
|
this.black = name.search(/Black/g) !== -1;
|
|
this.black = name.search(/Black/g) !== -1;
|
|
this.remeasure = Object.keys(this.widths).length > 0;
|
|
this.remeasure = Object.keys(this.widths).length > 0;
|
|
if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
|
|
if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
|
|
- var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
|
|
|
|
|
|
+ var GlyphMapForStandardFonts = (0, _standard_fonts.getGlyphMapForStandardFonts)();
|
|
var map = [];
|
|
var map = [];
|
|
for (charCode in GlyphMapForStandardFonts) {
|
|
for (charCode in GlyphMapForStandardFonts) {
|
|
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
|
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
|
}
|
|
}
|
|
if (/Arial-?Black/i.test(name)) {
|
|
if (/Arial-?Black/i.test(name)) {
|
|
- var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
|
|
|
|
|
|
+ var SupplementalGlyphMapForArialBlack = (0, _standard_fonts.getSupplementalGlyphMapForArialBlack)();
|
|
for (charCode in SupplementalGlyphMapForArialBlack) {
|
|
for (charCode in SupplementalGlyphMapForArialBlack) {
|
|
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
|
|
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
|
|
}
|
|
}
|
|
@@ -429,20 +400,20 @@ var Font = function FontClosure() {
|
|
this.toFontChar = map;
|
|
this.toFontChar = map;
|
|
this.toUnicode = new ToUnicodeMap(map);
|
|
this.toUnicode = new ToUnicodeMap(map);
|
|
} else if (/Symbol/i.test(fontName)) {
|
|
} else if (/Symbol/i.test(fontName)) {
|
|
- this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
|
|
|
|
|
|
+ this.toFontChar = buildToFontChar(_encodings.SymbolSetEncoding, (0, _glyphlist.getGlyphsUnicode)(), properties.differences);
|
|
} else if (/Dingbats/i.test(fontName)) {
|
|
} else if (/Dingbats/i.test(fontName)) {
|
|
if (/Wingdings/i.test(name)) {
|
|
if (/Wingdings/i.test(name)) {
|
|
- warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
|
|
|
|
|
|
+ (0, _util.warn)('Non-embedded Wingdings font, falling back to ZapfDingbats.');
|
|
}
|
|
}
|
|
- this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
|
|
|
|
|
|
+ this.toFontChar = buildToFontChar(_encodings.ZapfDingbatsEncoding, (0, _glyphlist.getDingbatsGlyphsUnicode)(), properties.differences);
|
|
} else if (isStandardFont) {
|
|
} else if (isStandardFont) {
|
|
- this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
|
|
|
|
|
|
+ this.toFontChar = buildToFontChar(properties.defaultEncoding, (0, _glyphlist.getGlyphsUnicode)(), properties.differences);
|
|
} else {
|
|
} else {
|
|
- glyphsUnicodeMap = getGlyphsUnicode();
|
|
|
|
|
|
+ glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
|
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
|
|
this.toUnicode.forEach(function (charCode, unicodeCharCode) {
|
|
if (!_this.composite) {
|
|
if (!_this.composite) {
|
|
glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
|
|
glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
|
|
- unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
|
|
|
|
|
|
+ unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
|
|
if (unicode !== -1) {
|
|
if (unicode !== -1) {
|
|
unicodeCharCode = unicode;
|
|
unicodeCharCode = unicode;
|
|
}
|
|
}
|
|
@@ -484,7 +455,7 @@ var Font = function FontClosure() {
|
|
var data;
|
|
var data;
|
|
switch (type) {
|
|
switch (type) {
|
|
case 'MMType1':
|
|
case 'MMType1':
|
|
- info('MMType1 font (' + name + '), falling back to Type1.');
|
|
|
|
|
|
+ (0, _util.info)('MMType1 font (' + name + '), falling back to Type1.');
|
|
case 'Type1':
|
|
case 'Type1':
|
|
case 'CIDFontType0':
|
|
case 'CIDFontType0':
|
|
this.mimetype = 'font/opentype';
|
|
this.mimetype = 'font/opentype';
|
|
@@ -503,7 +474,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- error('Font ' + type + ' is not supported');
|
|
|
|
|
|
+ (0, _util.error)('Font ' + type + ' is not supported');
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
this.data = data;
|
|
this.data = data;
|
|
@@ -541,11 +512,11 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
function isTrueTypeFile(file) {
|
|
function isTrueTypeFile(file) {
|
|
var header = file.peekBytes(4);
|
|
var header = file.peekBytes(4);
|
|
- return readUint32(header, 0) === 0x00010000;
|
|
|
|
|
|
+ return (0, _util.readUint32)(header, 0) === 0x00010000;
|
|
}
|
|
}
|
|
function isOpenTypeFile(file) {
|
|
function isOpenTypeFile(file) {
|
|
var header = file.peekBytes(4);
|
|
var header = file.peekBytes(4);
|
|
- return bytesToString(header) === 'OTTO';
|
|
|
|
|
|
+ return (0, _util.bytesToString)(header) === 'OTTO';
|
|
}
|
|
}
|
|
function isType1File(file) {
|
|
function isType1File(file) {
|
|
var header = file.peekBytes(2);
|
|
var header = file.peekBytes(2);
|
|
@@ -561,13 +532,13 @@ var Font = function FontClosure() {
|
|
var toFontChar = [],
|
|
var toFontChar = [],
|
|
unicode;
|
|
unicode;
|
|
for (var i = 0, ii = encoding.length; i < ii; i++) {
|
|
for (var i = 0, ii = encoding.length; i < ii; i++) {
|
|
- unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
|
|
|
|
|
|
+ unicode = (0, _unicode.getUnicodeForGlyph)(encoding[i], glyphsUnicodeMap);
|
|
if (unicode !== -1) {
|
|
if (unicode !== -1) {
|
|
toFontChar[i] = unicode;
|
|
toFontChar[i] = unicode;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (var charCode in differences) {
|
|
for (var charCode in differences) {
|
|
- unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
|
|
|
|
|
|
+ unicode = (0, _unicode.getUnicodeForGlyph)(differences[charCode], glyphsUnicodeMap);
|
|
if (unicode !== -1) {
|
|
if (unicode !== -1) {
|
|
toFontChar[+charCode] = unicode;
|
|
toFontChar[+charCode] = unicode;
|
|
}
|
|
}
|
|
@@ -662,7 +633,7 @@ var Font = function FontClosure() {
|
|
function createCmapTable(glyphs, numGlyphs) {
|
|
function createCmapTable(glyphs, numGlyphs) {
|
|
var ranges = getRanges(glyphs, numGlyphs);
|
|
var ranges = getRanges(glyphs, numGlyphs);
|
|
var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
|
|
var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
|
|
- var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
|
|
|
|
|
|
+ var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + (0, _util.string32)(4 + numTables * 8);
|
|
var i, ii, j, jj;
|
|
var i, ii, j, jj;
|
|
for (i = ranges.length - 1; i >= 0; --i) {
|
|
for (i = ranges.length - 1; i >= 0; --i) {
|
|
if (ranges[i][0] <= 0xFFFF) {
|
|
if (ranges[i][0] <= 0xFFFF) {
|
|
@@ -721,7 +692,7 @@ var Font = function FontClosure() {
|
|
var format31012 = '';
|
|
var format31012 = '';
|
|
var header31012 = '';
|
|
var header31012 = '';
|
|
if (numTables > 1) {
|
|
if (numTables > 1) {
|
|
- cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
|
|
|
|
|
|
+ cmap += '\x00\x03' + '\x00\x0A' + (0, _util.string32)(4 + numTables * 8 + 4 + format314.length);
|
|
format31012 = '';
|
|
format31012 = '';
|
|
for (i = 0, ii = ranges.length; i < ii; i++) {
|
|
for (i = 0, ii = ranges.length; i < ii; i++) {
|
|
range = ranges[i];
|
|
range = ranges[i];
|
|
@@ -731,19 +702,19 @@ var Font = function FontClosure() {
|
|
for (j = 1, jj = codes.length; j < jj; ++j) {
|
|
for (j = 1, jj = codes.length; j < jj; ++j) {
|
|
if (codes[j] !== codes[j - 1] + 1) {
|
|
if (codes[j] !== codes[j - 1] + 1) {
|
|
end = range[0] + j - 1;
|
|
end = range[0] + j - 1;
|
|
- format31012 += string32(start) + string32(end) + string32(code);
|
|
|
|
|
|
+ format31012 += (0, _util.string32)(start) + (0, _util.string32)(end) + (0, _util.string32)(code);
|
|
start = end + 1;
|
|
start = end + 1;
|
|
code = codes[j];
|
|
code = codes[j];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- format31012 += string32(start) + string32(range[1]) + string32(code);
|
|
|
|
|
|
+ format31012 += (0, _util.string32)(start) + (0, _util.string32)(range[1]) + (0, _util.string32)(code);
|
|
}
|
|
}
|
|
- header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
|
|
|
|
|
|
+ header31012 = '\x00\x0C' + '\x00\x00' + (0, _util.string32)(format31012.length + 16) + '\x00\x00\x00\x00' + (0, _util.string32)(format31012.length / 12);
|
|
}
|
|
}
|
|
return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
|
|
return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
|
|
}
|
|
}
|
|
function validateOS2Table(os2) {
|
|
function validateOS2Table(os2) {
|
|
- var stream = new Stream(os2.data);
|
|
|
|
|
|
+ var stream = new _stream.Stream(os2.data);
|
|
var version = stream.getUint16();
|
|
var version = stream.getUint16();
|
|
stream.getBytes(60);
|
|
stream.getBytes(60);
|
|
var selection = stream.getUint16();
|
|
var selection = stream.getUint16();
|
|
@@ -786,7 +757,7 @@ var Font = function FontClosure() {
|
|
if (lastCharIndex < code) {
|
|
if (lastCharIndex < code) {
|
|
lastCharIndex = code;
|
|
lastCharIndex = code;
|
|
}
|
|
}
|
|
- var position = getUnicodeRangeFor(code);
|
|
|
|
|
|
+ var position = (0, _unicode.getUnicodeRangeFor)(code);
|
|
if (position < 32) {
|
|
if (position < 32) {
|
|
ulUnicodeRange1 |= 1 << position;
|
|
ulUnicodeRange1 |= 1 << position;
|
|
} else if (position < 64) {
|
|
} else if (position < 64) {
|
|
@@ -796,7 +767,7 @@ var Font = function FontClosure() {
|
|
} else if (position < 123) {
|
|
} else if (position < 123) {
|
|
ulUnicodeRange4 |= 1 << position - 96;
|
|
ulUnicodeRange4 |= 1 << position - 96;
|
|
} else {
|
|
} else {
|
|
- error('Unicode ranges Bits > 123 are reserved for internal usage');
|
|
|
|
|
|
+ (0, _util.error)('Unicode ranges Bits > 123 are reserved for internal usage');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -804,7 +775,7 @@ var Font = function FontClosure() {
|
|
lastCharIndex = 255;
|
|
lastCharIndex = 255;
|
|
}
|
|
}
|
|
var bbox = properties.bbox || [0, 0, 0, 0];
|
|
var bbox = properties.bbox || [0, 0, 0, 0];
|
|
- var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
|
|
|
|
|
|
+ var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
|
|
var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
|
|
var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
|
|
var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
|
|
var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
|
|
var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
|
|
var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
|
|
@@ -813,11 +784,11 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
var winAscent = override.yMax || typoAscent;
|
|
var winAscent = override.yMax || typoAscent;
|
|
var winDescent = -override.yMin || -typoDescent;
|
|
var winDescent = -override.yMin || -typoDescent;
|
|
- return '\x00\x03' + '\x02\x24' + '\x01\xF4' + '\x00\x05' + '\x00\x00' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x00\x8C' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x01\xDF' + '\x00\x31' + '\x01\x02' + '\x00\x00' + '\x00\x00\x06' + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + '\x00\x00\x00\x00\x00\x00' + string32(ulUnicodeRange1) + string32(ulUnicodeRange2) + string32(ulUnicodeRange3) + string32(ulUnicodeRange4) + '\x2A\x32\x31\x2A' + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + '\x00\x64' + string16(winAscent) + string16(winDescent) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + '\x00\x03';
|
|
|
|
|
|
+ return '\x00\x03' + '\x02\x24' + '\x01\xF4' + '\x00\x05' + '\x00\x00' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x00\x8C' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x01\xDF' + '\x00\x31' + '\x01\x02' + '\x00\x00' + '\x00\x00\x06' + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + '\x00\x00\x00\x00\x00\x00' + (0, _util.string32)(ulUnicodeRange1) + (0, _util.string32)(ulUnicodeRange2) + (0, _util.string32)(ulUnicodeRange3) + (0, _util.string32)(ulUnicodeRange4) + '\x2A\x32\x31\x2A' + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + '\x00\x64' + string16(winAscent) + string16(winDescent) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + '\x00\x03';
|
|
}
|
|
}
|
|
function createPostTable(properties) {
|
|
function createPostTable(properties) {
|
|
var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
|
|
var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
|
|
- return '\x00\x03\x00\x00' + string32(angle) + '\x00\x00' + '\x00\x00' + string32(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
|
|
|
|
|
|
+ return '\x00\x03\x00\x00' + (0, _util.string32)(angle) + '\x00\x00' + '\x00\x00' + (0, _util.string32)(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
|
|
}
|
|
}
|
|
function createNameTable(name, proto) {
|
|
function createNameTable(name, proto) {
|
|
if (!proto) {
|
|
if (!proto) {
|
|
@@ -859,8 +830,8 @@ var Font = function FontClosure() {
|
|
mimetype: null,
|
|
mimetype: null,
|
|
encoding: null,
|
|
encoding: null,
|
|
get renderer() {
|
|
get renderer() {
|
|
- var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
|
|
|
|
- return shadow(this, 'renderer', renderer);
|
|
|
|
|
|
+ var renderer = _font_renderer.FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
|
|
|
|
+ return (0, _util.shadow)(this, 'renderer', renderer);
|
|
},
|
|
},
|
|
exportData: function Font_exportData() {
|
|
exportData: function Font_exportData() {
|
|
var data = {};
|
|
var data = {};
|
|
@@ -873,7 +844,7 @@ var Font = function FontClosure() {
|
|
},
|
|
},
|
|
checkAndRepair: function Font_checkAndRepair(name, font, properties) {
|
|
checkAndRepair: function Font_checkAndRepair(name, font, properties) {
|
|
function readTableEntry(file) {
|
|
function readTableEntry(file) {
|
|
- var tag = bytesToString(file.getBytes(4));
|
|
|
|
|
|
+ var tag = (0, _util.bytesToString)(file.getBytes(4));
|
|
var checksum = file.getInt32() >>> 0;
|
|
var checksum = file.getInt32() >>> 0;
|
|
var offset = file.getInt32() >>> 0;
|
|
var offset = file.getInt32() >>> 0;
|
|
var length = file.getInt32() >>> 0;
|
|
var length = file.getInt32() >>> 0;
|
|
@@ -896,7 +867,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
function readOpenTypeHeader(ttf) {
|
|
function readOpenTypeHeader(ttf) {
|
|
return {
|
|
return {
|
|
- version: bytesToString(ttf.getBytes(4)),
|
|
|
|
|
|
+ version: (0, _util.bytesToString)(ttf.getBytes(4)),
|
|
numTables: ttf.getUint16(),
|
|
numTables: ttf.getUint16(),
|
|
searchRange: ttf.getUint16(),
|
|
searchRange: ttf.getUint16(),
|
|
entrySelector: ttf.getUint16(),
|
|
entrySelector: ttf.getUint16(),
|
|
@@ -905,7 +876,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
|
|
function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
|
|
if (!cmap) {
|
|
if (!cmap) {
|
|
- warn('No cmap table available.');
|
|
|
|
|
|
+ (0, _util.warn)('No cmap table available.');
|
|
return {
|
|
return {
|
|
platformId: -1,
|
|
platformId: -1,
|
|
encodingId: -1,
|
|
encodingId: -1,
|
|
@@ -953,7 +924,7 @@ var Font = function FontClosure() {
|
|
font.pos = start + potentialTable.offset;
|
|
font.pos = start + potentialTable.offset;
|
|
}
|
|
}
|
|
if (!potentialTable || font.peekByte() === -1) {
|
|
if (!potentialTable || font.peekByte() === -1) {
|
|
- warn('Could not find a preferred cmap table.');
|
|
|
|
|
|
+ (0, _util.warn)('Could not find a preferred cmap table.');
|
|
return {
|
|
return {
|
|
platformId: -1,
|
|
platformId: -1,
|
|
encodingId: -1,
|
|
encodingId: -1,
|
|
@@ -1040,7 +1011,7 @@ var Font = function FontClosure() {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- warn('cmap table has unsupported format: ' + format);
|
|
|
|
|
|
+ (0, _util.warn)('cmap table has unsupported format: ' + format);
|
|
return {
|
|
return {
|
|
platformId: -1,
|
|
platformId: -1,
|
|
encodingId: -1,
|
|
encodingId: -1,
|
|
@@ -1075,7 +1046,7 @@ var Font = function FontClosure() {
|
|
font.pos += header.length - 2;
|
|
font.pos += header.length - 2;
|
|
var numOfMetrics = font.getUint16();
|
|
var numOfMetrics = font.getUint16();
|
|
if (numOfMetrics > numGlyphs) {
|
|
if (numOfMetrics > numGlyphs) {
|
|
- info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
|
|
|
|
|
|
+ (0, _util.info)('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
|
|
numOfMetrics = numGlyphs;
|
|
numOfMetrics = numGlyphs;
|
|
header.data[34] = (numOfMetrics & 0xff00) >> 8;
|
|
header.data[34] = (numOfMetrics & 0xff00) >> 8;
|
|
header.data[35] = numOfMetrics & 0x00ff;
|
|
header.data[35] = numOfMetrics & 0x00ff;
|
|
@@ -1153,7 +1124,7 @@ var Font = function FontClosure() {
|
|
var data = head.data;
|
|
var data = head.data;
|
|
var version = int32(data[0], data[1], data[2], data[3]);
|
|
var version = int32(data[0], data[1], data[2], data[3]);
|
|
if (version >> 16 !== 1) {
|
|
if (version >> 16 !== 1) {
|
|
- info('Attempting to fix invalid version in head table: ' + version);
|
|
|
|
|
|
+ (0, _util.info)('Attempting to fix invalid version in head table: ' + version);
|
|
data[0] = 0;
|
|
data[0] = 0;
|
|
data[1] = 1;
|
|
data[1] = 1;
|
|
data[2] = 0;
|
|
data[2] = 0;
|
|
@@ -1161,7 +1132,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
var indexToLocFormat = int16(data[50], data[51]);
|
|
var indexToLocFormat = int16(data[50], data[51]);
|
|
if (indexToLocFormat < 0 || indexToLocFormat > 1) {
|
|
if (indexToLocFormat < 0 || indexToLocFormat > 1) {
|
|
- info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
|
|
|
|
|
|
+ (0, _util.info)('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
|
|
var numGlyphsPlusOne = numGlyphs + 1;
|
|
var numGlyphsPlusOne = numGlyphs + 1;
|
|
if (locaLength === numGlyphsPlusOne << 1) {
|
|
if (locaLength === numGlyphsPlusOne << 1) {
|
|
data[50] = 0;
|
|
data[50] = 0;
|
|
@@ -1170,7 +1141,7 @@ var Font = function FontClosure() {
|
|
data[50] = 0;
|
|
data[50] = 0;
|
|
data[51] = 1;
|
|
data[51] = 1;
|
|
} else {
|
|
} else {
|
|
- warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
|
|
|
|
|
|
+ (0, _util.warn)('Could not fix indexToLocFormat: ' + indexToLocFormat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1308,7 +1279,7 @@ var Font = function FontClosure() {
|
|
case 0x00030000:
|
|
case 0x00030000:
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- warn('Unknown/unsupported post table version ' + version);
|
|
|
|
|
|
+ (0, _util.warn)('Unknown/unsupported post table version ' + version);
|
|
valid = false;
|
|
valid = false;
|
|
if (properties.defaultEncoding) {
|
|
if (properties.defaultEncoding) {
|
|
glyphNames = properties.defaultEncoding;
|
|
glyphNames = properties.defaultEncoding;
|
|
@@ -1365,7 +1336,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
names[1][nameIndex] = str;
|
|
names[1][nameIndex] = str;
|
|
} else {
|
|
} else {
|
|
- names[0][nameIndex] = bytesToString(font.getBytes(record.length));
|
|
|
|
|
|
+ names[0][nameIndex] = (0, _util.bytesToString)(font.getBytes(record.length));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return names;
|
|
return names;
|
|
@@ -1443,7 +1414,7 @@ var Font = function FontClosure() {
|
|
functionsCalled.push(funcId);
|
|
functionsCalled.push(funcId);
|
|
pc = ttContext.functionsDefined[funcId];
|
|
pc = ttContext.functionsDefined[funcId];
|
|
if (!pc) {
|
|
if (!pc) {
|
|
- warn('TT: CALL non-existent function');
|
|
|
|
|
|
+ (0, _util.warn)('TT: CALL non-existent function');
|
|
ttContext.hintsValid = false;
|
|
ttContext.hintsValid = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1453,7 +1424,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
} else if (op === 0x2C && !tooComplexToFollowFunctions) {
|
|
} else if (op === 0x2C && !tooComplexToFollowFunctions) {
|
|
if (inFDEF || inELSE) {
|
|
if (inFDEF || inELSE) {
|
|
- warn('TT: nested FDEFs not allowed');
|
|
|
|
|
|
+ (0, _util.warn)('TT: nested FDEFs not allowed');
|
|
tooComplexToFollowFunctions = true;
|
|
tooComplexToFollowFunctions = true;
|
|
}
|
|
}
|
|
inFDEF = true;
|
|
inFDEF = true;
|
|
@@ -1470,7 +1441,7 @@ var Font = function FontClosure() {
|
|
} else {
|
|
} else {
|
|
pc = callstack.pop();
|
|
pc = callstack.pop();
|
|
if (!pc) {
|
|
if (!pc) {
|
|
- warn('TT: ENDF bad stack');
|
|
|
|
|
|
+ (0, _util.warn)('TT: ENDF bad stack');
|
|
ttContext.hintsValid = false;
|
|
ttContext.hintsValid = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1481,7 +1452,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
} else if (op === 0x89) {
|
|
} else if (op === 0x89) {
|
|
if (inFDEF || inELSE) {
|
|
if (inFDEF || inELSE) {
|
|
- warn('TT: nested IDEFs not allowed');
|
|
|
|
|
|
+ (0, _util.warn)('TT: nested IDEFs not allowed');
|
|
tooComplexToFollowFunctions = true;
|
|
tooComplexToFollowFunctions = true;
|
|
}
|
|
}
|
|
inFDEF = true;
|
|
inFDEF = true;
|
|
@@ -1527,7 +1498,7 @@ var Font = function FontClosure() {
|
|
content.push(new Uint8Array(i - data.length));
|
|
content.push(new Uint8Array(i - data.length));
|
|
}
|
|
}
|
|
if (lastDeff > lastEndf) {
|
|
if (lastDeff > lastEndf) {
|
|
- warn('TT: complementing a missing function tail');
|
|
|
|
|
|
+ (0, _util.warn)('TT: complementing a missing function tail');
|
|
content.push(new Uint8Array([0x22, 0x2D]));
|
|
content.push(new Uint8Array([0x22, 0x2D]));
|
|
}
|
|
}
|
|
foldTTTable(table, content);
|
|
foldTTTable(table, content);
|
|
@@ -1537,18 +1508,18 @@ var Font = function FontClosure() {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (ttContext.functionsDefined.length > maxFunctionDefs) {
|
|
if (ttContext.functionsDefined.length > maxFunctionDefs) {
|
|
- warn('TT: more functions defined than expected');
|
|
|
|
|
|
+ (0, _util.warn)('TT: more functions defined than expected');
|
|
ttContext.hintsValid = false;
|
|
ttContext.hintsValid = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
|
|
for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
|
|
if (j > maxFunctionDefs) {
|
|
if (j > maxFunctionDefs) {
|
|
- warn('TT: invalid function id: ' + j);
|
|
|
|
|
|
+ (0, _util.warn)('TT: invalid function id: ' + j);
|
|
ttContext.hintsValid = false;
|
|
ttContext.hintsValid = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
|
|
if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
|
|
- warn('TT: undefined function: ' + j);
|
|
|
|
|
|
+ (0, _util.warn)('TT: undefined function: ' + j);
|
|
ttContext.hintsValid = false;
|
|
ttContext.hintsValid = false;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1596,7 +1567,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
return ttContext.hintsValid;
|
|
return ttContext.hintsValid;
|
|
}
|
|
}
|
|
- font = new Stream(new Uint8Array(font.getBytes()));
|
|
|
|
|
|
+ font = new _stream.Stream(new Uint8Array(font.getBytes()));
|
|
var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
|
|
var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
|
|
var header = readOpenTypeHeader(font);
|
|
var header = readOpenTypeHeader(font);
|
|
var numTables = header.numTables;
|
|
var numTables = header.numTables;
|
|
@@ -1624,7 +1595,7 @@ var Font = function FontClosure() {
|
|
var isTrueType = !tables['CFF '];
|
|
var isTrueType = !tables['CFF '];
|
|
if (!isTrueType) {
|
|
if (!isTrueType) {
|
|
if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
|
|
if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
|
|
- cffFile = new Stream(tables['CFF '].data);
|
|
|
|
|
|
+ cffFile = new _stream.Stream(tables['CFF '].data);
|
|
cff = new CFFFont(cffFile, properties);
|
|
cff = new CFFFont(cffFile, properties);
|
|
adjustWidths(properties);
|
|
adjustWidths(properties);
|
|
return this.convert(name, cff, properties);
|
|
return this.convert(name, cff, properties);
|
|
@@ -1637,10 +1608,10 @@ var Font = function FontClosure() {
|
|
this.isOpenType = true;
|
|
this.isOpenType = true;
|
|
} else {
|
|
} else {
|
|
if (!tables['loca']) {
|
|
if (!tables['loca']) {
|
|
- error('Required "loca" table is not found');
|
|
|
|
|
|
+ (0, _util.error)('Required "loca" table is not found');
|
|
}
|
|
}
|
|
if (!tables['glyf']) {
|
|
if (!tables['glyf']) {
|
|
- warn('Required "glyf" table is not found -- trying to recover.');
|
|
|
|
|
|
+ (0, _util.warn)('Required "glyf" table is not found -- trying to recover.');
|
|
tables['glyf'] = {
|
|
tables['glyf'] = {
|
|
tag: 'glyf',
|
|
tag: 'glyf',
|
|
data: new Uint8Array(0)
|
|
data: new Uint8Array(0)
|
|
@@ -1649,7 +1620,7 @@ var Font = function FontClosure() {
|
|
this.isOpenType = false;
|
|
this.isOpenType = false;
|
|
}
|
|
}
|
|
if (!tables['maxp']) {
|
|
if (!tables['maxp']) {
|
|
- error('Required "maxp" table is not found');
|
|
|
|
|
|
+ (0, _util.error)('Required "maxp" table is not found');
|
|
}
|
|
}
|
|
font.pos = (font.start || 0) + tables['maxp'].offset;
|
|
font.pos = (font.start || 0) + tables['maxp'].offset;
|
|
var version = font.getInt32();
|
|
var version = font.getInt32();
|
|
@@ -1680,7 +1651,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
|
|
sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
|
|
if (!tables['head']) {
|
|
if (!tables['head']) {
|
|
- error('Required "head" table is not found');
|
|
|
|
|
|
+ (0, _util.error)('Required "head" table is not found');
|
|
}
|
|
}
|
|
sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
|
|
sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
|
|
var missingGlyphs = Object.create(null);
|
|
var missingGlyphs = Object.create(null);
|
|
@@ -1689,7 +1660,7 @@ var Font = function FontClosure() {
|
|
missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
|
|
missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
|
|
}
|
|
}
|
|
if (!tables['hhea']) {
|
|
if (!tables['hhea']) {
|
|
- error('Required "hhea" table is not found');
|
|
|
|
|
|
+ (0, _util.error)('Required "hhea" table is not found');
|
|
}
|
|
}
|
|
if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
|
|
if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
|
|
tables['hhea'].data[10] = 0xFF;
|
|
tables['hhea'].data[10] = 0xFF;
|
|
@@ -1722,7 +1693,7 @@ var Font = function FontClosure() {
|
|
if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
|
|
if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
|
|
|
|
|
|
+ if (widths && widthCode >= 0 && (0, _util.isNum)(widths[widthCode])) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
@@ -1731,7 +1702,7 @@ var Font = function FontClosure() {
|
|
var cidToGidMap = properties.cidToGidMap || [];
|
|
var cidToGidMap = properties.cidToGidMap || [];
|
|
var isCidToGidMapEmpty = cidToGidMap.length === 0;
|
|
var isCidToGidMapEmpty = cidToGidMap.length === 0;
|
|
properties.cMap.forEach(function (charCode, cid) {
|
|
properties.cMap.forEach(function (charCode, cid) {
|
|
- assert(cid <= 0xffff, 'Max size of CID is 65,535');
|
|
|
|
|
|
+ (0, _util.assert)(cid <= 0xffff, 'Max size of CID is 65,535');
|
|
var glyphId = -1;
|
|
var glyphId = -1;
|
|
if (isCidToGidMapEmpty) {
|
|
if (isCidToGidMapEmpty) {
|
|
glyphId = cid;
|
|
glyphId = cid;
|
|
@@ -1751,12 +1722,12 @@ var Font = function FontClosure() {
|
|
var cmapEncodingId = cmapTable.encodingId;
|
|
var cmapEncodingId = cmapTable.encodingId;
|
|
var cmapMappings = cmapTable.mappings;
|
|
var cmapMappings = cmapTable.mappings;
|
|
var cmapMappingsLength = cmapMappings.length;
|
|
var cmapMappingsLength = cmapMappings.length;
|
|
- if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
|
|
|
|
|
|
+ if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!(0, _encodings.getEncoding)(properties.baseEncodingName)) {
|
|
var baseEncoding = [];
|
|
var baseEncoding = [];
|
|
if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
|
|
if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
|
|
- baseEncoding = getEncoding(properties.baseEncodingName);
|
|
|
|
|
|
+ baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
|
|
}
|
|
}
|
|
- var glyphsUnicodeMap = getGlyphsUnicode();
|
|
|
|
|
|
+ var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
|
for (charCode = 0; charCode < 256; charCode++) {
|
|
for (charCode = 0; charCode < 256; charCode++) {
|
|
var glyphName, standardGlyphName;
|
|
var glyphName, standardGlyphName;
|
|
if (this.differences && charCode in this.differences) {
|
|
if (this.differences && charCode in this.differences) {
|
|
@@ -1764,7 +1735,7 @@ var Font = function FontClosure() {
|
|
} else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
|
|
} else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
|
|
glyphName = baseEncoding[charCode];
|
|
glyphName = baseEncoding[charCode];
|
|
} else {
|
|
} else {
|
|
- glyphName = StandardEncoding[charCode];
|
|
|
|
|
|
+ glyphName = _encodings.StandardEncoding[charCode];
|
|
}
|
|
}
|
|
if (!glyphName) {
|
|
if (!glyphName) {
|
|
continue;
|
|
continue;
|
|
@@ -1776,7 +1747,7 @@ var Font = function FontClosure() {
|
|
unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
|
|
unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
|
|
isUnicode = true;
|
|
isUnicode = true;
|
|
} else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
|
|
} else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
|
|
- unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
|
|
|
|
|
|
+ unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
|
|
}
|
|
}
|
|
var found = false;
|
|
var found = false;
|
|
for (i = 0; i < cmapMappingsLength; ++i) {
|
|
for (i = 0; i < cmapMappingsLength; ++i) {
|
|
@@ -1838,13 +1809,13 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
if (!isTrueType) {
|
|
if (!isTrueType) {
|
|
try {
|
|
try {
|
|
- cffFile = new Stream(tables['CFF '].data);
|
|
|
|
- var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
|
|
|
|
|
|
+ cffFile = new _stream.Stream(tables['CFF '].data);
|
|
|
|
+ var parser = new _cff_parser.CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
|
|
cff = parser.parse();
|
|
cff = parser.parse();
|
|
- var compiler = new CFFCompiler(cff);
|
|
|
|
|
|
+ var compiler = new _cff_parser.CFFCompiler(cff);
|
|
tables['CFF '].data = compiler.compile();
|
|
tables['CFF '].data = compiler.compile();
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- warn('Failed to compile font ' + properties.loadedName);
|
|
|
|
|
|
+ (0, _util.warn)('Failed to compile font ' + properties.loadedName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!tables['name']) {
|
|
if (!tables['name']) {
|
|
@@ -1894,14 +1865,14 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
var seacs = font.seacs;
|
|
var seacs = font.seacs;
|
|
if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
|
|
if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
|
|
- var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
|
|
|
|
|
|
+ var matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;
|
|
var charset = font.getCharset();
|
|
var charset = font.getCharset();
|
|
var seacMap = Object.create(null);
|
|
var seacMap = Object.create(null);
|
|
for (var glyphId in seacs) {
|
|
for (var glyphId in seacs) {
|
|
glyphId |= 0;
|
|
glyphId |= 0;
|
|
var seac = seacs[glyphId];
|
|
var seac = seacs[glyphId];
|
|
- var baseGlyphName = StandardEncoding[seac[2]];
|
|
|
|
- var accentGlyphName = StandardEncoding[seac[3]];
|
|
|
|
|
|
+ var baseGlyphName = _encodings.StandardEncoding[seac[2]];
|
|
|
|
+ var accentGlyphName = _encodings.StandardEncoding[seac[3]];
|
|
var baseGlyphId = charset.indexOf(baseGlyphName);
|
|
var baseGlyphId = charset.indexOf(baseGlyphName);
|
|
var accentGlyphId = charset.indexOf(accentGlyphName);
|
|
var accentGlyphId = charset.indexOf(accentGlyphName);
|
|
if (baseGlyphId < 0 || accentGlyphId < 0) {
|
|
if (baseGlyphId < 0 || accentGlyphId < 0) {
|
|
@@ -1929,7 +1900,7 @@ var Font = function FontClosure() {
|
|
}
|
|
}
|
|
properties.seacMap = seacMap;
|
|
properties.seacMap = seacMap;
|
|
}
|
|
}
|
|
- var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
|
|
|
|
|
|
+ var unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
|
|
var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
|
|
var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
|
|
builder.addTable('CFF ', font.data);
|
|
builder.addTable('CFF ', font.data);
|
|
builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
|
|
builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
|
|
@@ -1969,7 +1940,7 @@ var Font = function FontClosure() {
|
|
width = this.widths[glyphName];
|
|
width = this.widths[glyphName];
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- var glyphsUnicodeMap = getGlyphsUnicode();
|
|
|
|
|
|
+ var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
|
var glyphUnicode = glyphsUnicodeMap[glyphName];
|
|
var glyphUnicode = glyphsUnicodeMap[glyphName];
|
|
var charcode = 0;
|
|
var charcode = 0;
|
|
if (this.composite) {
|
|
if (this.composite) {
|
|
@@ -1999,7 +1970,7 @@ var Font = function FontClosure() {
|
|
widthCode = this.cMap.lookup(charcode);
|
|
widthCode = this.cMap.lookup(charcode);
|
|
}
|
|
}
|
|
width = this.widths[widthCode];
|
|
width = this.widths[widthCode];
|
|
- width = isNum(width) ? width : this.defaultWidth;
|
|
|
|
|
|
+ width = (0, _util.isNum)(width) ? width : this.defaultWidth;
|
|
var vmetric = this.vmetrics && this.vmetrics[widthCode];
|
|
var vmetric = this.vmetrics && this.vmetrics[widthCode];
|
|
var unicode = this.toUnicode.get(charcode) || charcode;
|
|
var unicode = this.toUnicode.get(charcode) || charcode;
|
|
if (typeof unicode === 'number') {
|
|
if (typeof unicode === 'number') {
|
|
@@ -2008,7 +1979,7 @@ var Font = function FontClosure() {
|
|
var isInFont = charcode in this.toFontChar;
|
|
var isInFont = charcode in this.toFontChar;
|
|
fontCharCode = this.toFontChar[charcode] || charcode;
|
|
fontCharCode = this.toFontChar[charcode] || charcode;
|
|
if (this.missingFile) {
|
|
if (this.missingFile) {
|
|
- fontCharCode = mapSpecialUnicodeValues(fontCharCode);
|
|
|
|
|
|
+ fontCharCode = (0, _unicode.mapSpecialUnicodeValues)(fontCharCode);
|
|
}
|
|
}
|
|
if (this.isType3Font) {
|
|
if (this.isType3Font) {
|
|
operatorListId = fontCharCode;
|
|
operatorListId = fontCharCode;
|
|
@@ -2091,7 +2062,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|
var glyphId, charCode, baseEncoding;
|
|
var glyphId, charCode, baseEncoding;
|
|
var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
|
|
var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
|
|
if (properties.baseEncodingName) {
|
|
if (properties.baseEncodingName) {
|
|
- baseEncoding = getEncoding(properties.baseEncodingName);
|
|
|
|
|
|
+ baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
|
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
|
if (glyphId >= 0) {
|
|
if (glyphId >= 0) {
|
|
@@ -2105,7 +2076,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|
charCodeToGlyphId[charCode] = builtInEncoding[charCode];
|
|
charCodeToGlyphId[charCode] = builtInEncoding[charCode];
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- baseEncoding = StandardEncoding;
|
|
|
|
|
|
+ baseEncoding = _encodings.StandardEncoding;
|
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
|
if (glyphId >= 0) {
|
|
if (glyphId >= 0) {
|
|
@@ -2123,7 +2094,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|
glyphId = glyphNames.indexOf(glyphName);
|
|
glyphId = glyphNames.indexOf(glyphName);
|
|
if (glyphId === -1) {
|
|
if (glyphId === -1) {
|
|
if (!glyphsUnicodeMap) {
|
|
if (!glyphsUnicodeMap) {
|
|
- glyphsUnicodeMap = getGlyphsUnicode();
|
|
|
|
|
|
+ glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
|
|
}
|
|
}
|
|
var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
|
|
var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
|
|
if (standardGlyphName !== glyphName) {
|
|
if (standardGlyphName !== glyphName) {
|
|
@@ -2154,7 +2125,7 @@ var Type1Font = function Type1FontClosure() {
|
|
}
|
|
}
|
|
if (j >= signatureLength) {
|
|
if (j >= signatureLength) {
|
|
i += j;
|
|
i += j;
|
|
- while (i < streamBytesLength && isSpace(streamBytes[i])) {
|
|
|
|
|
|
+ while (i < streamBytesLength && (0, _util.isSpace)(streamBytes[i])) {
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
found = true;
|
|
found = true;
|
|
@@ -2175,7 +2146,7 @@ var Type1Font = function Type1FontClosure() {
|
|
headerBytes = stream.getBytes(suggestedLength);
|
|
headerBytes = stream.getBytes(suggestedLength);
|
|
headerBytesLength = headerBytes.length;
|
|
headerBytesLength = headerBytes.length;
|
|
} catch (ex) {
|
|
} catch (ex) {
|
|
- if (ex instanceof MissingDataException) {
|
|
|
|
|
|
+ if (ex instanceof _util.MissingDataException) {
|
|
throw ex;
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2183,12 +2154,12 @@ var Type1Font = function Type1FontClosure() {
|
|
block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
|
|
block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
|
|
if (block.found && block.length === suggestedLength) {
|
|
if (block.found && block.length === suggestedLength) {
|
|
return {
|
|
return {
|
|
- stream: new Stream(headerBytes),
|
|
|
|
|
|
+ stream: new _stream.Stream(headerBytes),
|
|
length: suggestedLength
|
|
length: suggestedLength
|
|
};
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- warn('Invalid "Length1" property in Type1 font -- trying to recover.');
|
|
|
|
|
|
+ (0, _util.warn)('Invalid "Length1" property in Type1 font -- trying to recover.');
|
|
stream.pos = streamStartPos;
|
|
stream.pos = streamStartPos;
|
|
var SCAN_BLOCK_LENGTH = 2048;
|
|
var SCAN_BLOCK_LENGTH = 2048;
|
|
var actualLength;
|
|
var actualLength;
|
|
@@ -2207,20 +2178,20 @@ var Type1Font = function Type1FontClosure() {
|
|
stream.pos = streamStartPos;
|
|
stream.pos = streamStartPos;
|
|
if (actualLength) {
|
|
if (actualLength) {
|
|
return {
|
|
return {
|
|
- stream: new Stream(stream.getBytes(actualLength)),
|
|
|
|
|
|
+ stream: new _stream.Stream(stream.getBytes(actualLength)),
|
|
length: actualLength
|
|
length: actualLength
|
|
};
|
|
};
|
|
}
|
|
}
|
|
- warn('Unable to recover "Length1" property in Type1 font -- using as is.');
|
|
|
|
|
|
+ (0, _util.warn)('Unable to recover "Length1" property in Type1 font -- using as is.');
|
|
return {
|
|
return {
|
|
- stream: new Stream(stream.getBytes(suggestedLength)),
|
|
|
|
|
|
+ stream: new _stream.Stream(stream.getBytes(suggestedLength)),
|
|
length: suggestedLength
|
|
length: suggestedLength
|
|
};
|
|
};
|
|
}
|
|
}
|
|
function getEexecBlock(stream, suggestedLength) {
|
|
function getEexecBlock(stream, suggestedLength) {
|
|
var eexecBytes = stream.getBytes();
|
|
var eexecBytes = stream.getBytes();
|
|
return {
|
|
return {
|
|
- stream: new Stream(eexecBytes),
|
|
|
|
|
|
+ stream: new _stream.Stream(eexecBytes),
|
|
length: eexecBytes.length
|
|
length: eexecBytes.length
|
|
};
|
|
};
|
|
}
|
|
}
|
|
@@ -2236,7 +2207,7 @@ var Type1Font = function Type1FontClosure() {
|
|
}
|
|
}
|
|
var headerBlock = getHeaderBlock(file, headerBlockLength);
|
|
var headerBlock = getHeaderBlock(file, headerBlockLength);
|
|
headerBlockLength = headerBlock.length;
|
|
headerBlockLength = headerBlock.length;
|
|
- var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
|
|
|
|
|
|
+ var headerBlockParser = new _type1_parser.Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
|
|
headerBlockParser.extractFontHeader(properties);
|
|
headerBlockParser.extractFontHeader(properties);
|
|
if (pfbHeaderPresent) {
|
|
if (pfbHeaderPresent) {
|
|
pfbHeader = file.getBytes(PFB_HEADER_SIZE);
|
|
pfbHeader = file.getBytes(PFB_HEADER_SIZE);
|
|
@@ -2244,7 +2215,7 @@ var Type1Font = function Type1FontClosure() {
|
|
}
|
|
}
|
|
var eexecBlock = getEexecBlock(file, eexecBlockLength);
|
|
var eexecBlock = getEexecBlock(file, eexecBlockLength);
|
|
eexecBlockLength = eexecBlock.length;
|
|
eexecBlockLength = eexecBlock.length;
|
|
- var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
|
|
|
|
|
|
+ var eexecBlockParser = new _type1_parser.Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
|
|
var data = eexecBlockParser.extractFontProgram();
|
|
var data = eexecBlockParser.extractFontProgram();
|
|
for (var info in data.properties) {
|
|
for (var info in data.properties) {
|
|
properties[info] = data.properties[info];
|
|
properties[info] = data.properties[info];
|
|
@@ -2326,10 +2297,10 @@ var Type1Font = function Type1FontClosure() {
|
|
return type2Subrs;
|
|
return type2Subrs;
|
|
},
|
|
},
|
|
wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
|
|
wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
|
|
- var cff = new CFF();
|
|
|
|
- cff.header = new CFFHeader(1, 0, 4, 4);
|
|
|
|
|
|
+ var cff = new _cff_parser.CFF();
|
|
|
|
+ cff.header = new _cff_parser.CFFHeader(1, 0, 4, 4);
|
|
cff.names = [name];
|
|
cff.names = [name];
|
|
- var topDict = new CFFTopDict();
|
|
|
|
|
|
+ var topDict = new _cff_parser.CFFTopDict();
|
|
topDict.setByName('version', 391);
|
|
topDict.setByName('version', 391);
|
|
topDict.setByName('Notice', 392);
|
|
topDict.setByName('Notice', 392);
|
|
topDict.setByName('FullName', 393);
|
|
topDict.setByName('FullName', 393);
|
|
@@ -2342,26 +2313,26 @@ var Type1Font = function Type1FontClosure() {
|
|
topDict.setByName('CharStrings', null);
|
|
topDict.setByName('CharStrings', null);
|
|
topDict.setByName('Private', null);
|
|
topDict.setByName('Private', null);
|
|
cff.topDict = topDict;
|
|
cff.topDict = topDict;
|
|
- var strings = new CFFStrings();
|
|
|
|
|
|
+ var strings = new _cff_parser.CFFStrings();
|
|
strings.add('Version 0.11');
|
|
strings.add('Version 0.11');
|
|
strings.add('See original notice');
|
|
strings.add('See original notice');
|
|
strings.add(name);
|
|
strings.add(name);
|
|
strings.add(name);
|
|
strings.add(name);
|
|
strings.add('Medium');
|
|
strings.add('Medium');
|
|
cff.strings = strings;
|
|
cff.strings = strings;
|
|
- cff.globalSubrIndex = new CFFIndex();
|
|
|
|
|
|
+ cff.globalSubrIndex = new _cff_parser.CFFIndex();
|
|
var count = glyphs.length;
|
|
var count = glyphs.length;
|
|
var charsetArray = [0];
|
|
var charsetArray = [0];
|
|
var i, ii;
|
|
var i, ii;
|
|
for (i = 0; i < count; i++) {
|
|
for (i = 0; i < count; i++) {
|
|
- var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
|
|
|
|
|
|
+ var index = _cff_parser.CFFStandardStrings.indexOf(charstrings[i].glyphName);
|
|
if (index === -1) {
|
|
if (index === -1) {
|
|
index = 0;
|
|
index = 0;
|
|
}
|
|
}
|
|
charsetArray.push(index >> 8 & 0xff, index & 0xff);
|
|
charsetArray.push(index >> 8 & 0xff, index & 0xff);
|
|
}
|
|
}
|
|
- cff.charset = new CFFCharset(false, 0, [], charsetArray);
|
|
|
|
- var charStringsIndex = new CFFIndex();
|
|
|
|
|
|
+ cff.charset = new _cff_parser.CFFCharset(false, 0, [], charsetArray);
|
|
|
|
+ var charStringsIndex = new _cff_parser.CFFIndex();
|
|
charStringsIndex.add([0x8B, 0x0E]);
|
|
charStringsIndex.add([0x8B, 0x0E]);
|
|
for (i = 0; i < count; i++) {
|
|
for (i = 0; i < count; i++) {
|
|
var glyph = glyphs[i];
|
|
var glyph = glyphs[i];
|
|
@@ -2372,7 +2343,7 @@ var Type1Font = function Type1FontClosure() {
|
|
charStringsIndex.add(glyph);
|
|
charStringsIndex.add(glyph);
|
|
}
|
|
}
|
|
cff.charStrings = charStringsIndex;
|
|
cff.charStrings = charStringsIndex;
|
|
- var privateDict = new CFFPrivateDict();
|
|
|
|
|
|
+ var privateDict = new _cff_parser.CFFPrivateDict();
|
|
privateDict.setByName('Subrs', null);
|
|
privateDict.setByName('Subrs', null);
|
|
var fields = ['BlueValues', 'OtherBlues', 'FamilyBlues', 'FamilyOtherBlues', 'StemSnapH', 'StemSnapV', 'BlueShift', 'BlueFuzz', 'BlueScale', 'LanguageGroup', 'ExpansionFactor', 'ForceBold', 'StdHW', 'StdVW'];
|
|
var fields = ['BlueValues', 'OtherBlues', 'FamilyBlues', 'FamilyOtherBlues', 'StemSnapH', 'StemSnapV', 'BlueShift', 'BlueFuzz', 'BlueScale', 'LanguageGroup', 'ExpansionFactor', 'ForceBold', 'StdHW', 'StdVW'];
|
|
for (i = 0, ii = fields.length; i < ii; i++) {
|
|
for (i = 0, ii = fields.length; i < ii; i++) {
|
|
@@ -2381,7 +2352,7 @@ var Type1Font = function Type1FontClosure() {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
var value = properties.privateData[field];
|
|
var value = properties.privateData[field];
|
|
- if (isArray(value)) {
|
|
|
|
|
|
+ if ((0, _util.isArray)(value)) {
|
|
for (var j = value.length - 1; j > 0; j--) {
|
|
for (var j = value.length - 1; j > 0; j--) {
|
|
value[j] -= value[j - 1];
|
|
value[j] -= value[j - 1];
|
|
}
|
|
}
|
|
@@ -2389,12 +2360,12 @@ var Type1Font = function Type1FontClosure() {
|
|
privateDict.setByName(field, value);
|
|
privateDict.setByName(field, value);
|
|
}
|
|
}
|
|
cff.topDict.privateDict = privateDict;
|
|
cff.topDict.privateDict = privateDict;
|
|
- var subrIndex = new CFFIndex();
|
|
|
|
|
|
+ var subrIndex = new _cff_parser.CFFIndex();
|
|
for (i = 0, ii = subrs.length; i < ii; i++) {
|
|
for (i = 0, ii = subrs.length; i < ii; i++) {
|
|
subrIndex.add(subrs[i]);
|
|
subrIndex.add(subrs[i]);
|
|
}
|
|
}
|
|
privateDict.subrsIndex = subrIndex;
|
|
privateDict.subrsIndex = subrIndex;
|
|
- var compiler = new CFFCompiler(cff);
|
|
|
|
|
|
+ var compiler = new _cff_parser.CFFCompiler(cff);
|
|
return compiler.compile();
|
|
return compiler.compile();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -2403,14 +2374,14 @@ var Type1Font = function Type1FontClosure() {
|
|
var CFFFont = function CFFFontClosure() {
|
|
var CFFFont = function CFFFontClosure() {
|
|
function CFFFont(file, properties) {
|
|
function CFFFont(file, properties) {
|
|
this.properties = properties;
|
|
this.properties = properties;
|
|
- var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
|
|
|
|
|
|
+ var parser = new _cff_parser.CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
|
|
this.cff = parser.parse();
|
|
this.cff = parser.parse();
|
|
- var compiler = new CFFCompiler(this.cff);
|
|
|
|
|
|
+ var compiler = new _cff_parser.CFFCompiler(this.cff);
|
|
this.seacs = this.cff.seacs;
|
|
this.seacs = this.cff.seacs;
|
|
try {
|
|
try {
|
|
this.data = compiler.compile();
|
|
this.data = compiler.compile();
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- warn('Failed to compile font ' + properties.loadedName);
|
|
|
|
|
|
+ (0, _util.warn)('Failed to compile font ' + properties.loadedName);
|
|
this.data = file;
|
|
this.data = file;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2451,7 +2422,7 @@ var CFFFont = function CFFFontClosure() {
|
|
}();
|
|
}();
|
|
(function checkSeacSupport() {
|
|
(function checkSeacSupport() {
|
|
if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
|
|
if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
|
|
- SEAC_ANALYSIS_ENABLED = true;
|
|
|
|
|
|
+ exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED = true;
|
|
}
|
|
}
|
|
})();
|
|
})();
|
|
(function checkChromeWindows() {
|
|
(function checkChromeWindows() {
|
|
@@ -2465,7 +2436,7 @@ exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
|
|
exports.ErrorFont = ErrorFont;
|
|
exports.ErrorFont = ErrorFont;
|
|
exports.Font = Font;
|
|
exports.Font = Font;
|
|
exports.FontFlags = FontFlags;
|
|
exports.FontFlags = FontFlags;
|
|
|
|
+exports.ToUnicodeMap = ToUnicodeMap;
|
|
exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
|
|
exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
|
|
exports.ProblematicCharRanges = ProblematicCharRanges;
|
|
exports.ProblematicCharRanges = ProblematicCharRanges;
|
|
-exports.ToUnicodeMap = ToUnicodeMap;
|
|
|
|
exports.getFontType = getFontType;
|
|
exports.getFontType = getFontType;
|