Fix a few warnings
This commit is contained in:
parent
ac5db21fb1
commit
688d7f28f8
181
fonts.js
181
fonts.js
@ -67,7 +67,7 @@ var Fonts = (function Fonts() {
|
|||||||
markLoaded(fontName);
|
markLoaded(fontName);
|
||||||
},
|
},
|
||||||
lookup: function fonts_lookup(fontName) {
|
lookup: function fonts_lookup(fontName) {
|
||||||
return fonts[fontName];
|
return (fontName in fonts) ? fonts[fontName] : null;
|
||||||
},
|
},
|
||||||
setActive: function fonts_setActive(fontName, size) {
|
setActive: function fonts_setActive(fontName, size) {
|
||||||
current = fonts[fontName];
|
current = fonts[fontName];
|
||||||
@ -126,7 +126,7 @@ var Fonts = (function Fonts() {
|
|||||||
var FontLoader = {
|
var FontLoader = {
|
||||||
listeningForFontLoad: false,
|
listeningForFontLoad: false,
|
||||||
|
|
||||||
bind: function(fonts, callback) {
|
bind: function font_bind(fonts, callback) {
|
||||||
function checkFontsLoaded() {
|
function checkFontsLoaded() {
|
||||||
for (var i = 0; i < fonts.length; i++) {
|
for (var i = 0; i < fonts.length; i++) {
|
||||||
var font = fonts[i];
|
var font = fonts[i];
|
||||||
@ -178,7 +178,7 @@ var FontLoader = {
|
|||||||
// loaded in a subdocument. It's expected that the load of |rules|
|
// loaded in a subdocument. It's expected that the load of |rules|
|
||||||
// has already started in this (outer) document, so that they should
|
// has already started in this (outer) document, so that they should
|
||||||
// be ordered before the load in the subdocument.
|
// be ordered before the load in the subdocument.
|
||||||
prepareFontLoadEvent: function(rules, names) {
|
prepareFontLoadEvent: function prepareFontLoadEvent(rules, names) {
|
||||||
/** Hack begin */
|
/** Hack begin */
|
||||||
// There's no event when a font has finished downloading so the
|
// There's no event when a font has finished downloading so the
|
||||||
// following code is a dirty hack to 'guess' when a font is
|
// following code is a dirty hack to 'guess' when a font is
|
||||||
@ -412,7 +412,7 @@ function getUnicodeRangeFor(value) {
|
|||||||
* var type1Font = new Font("MyFontName", binaryFile, propertiesObject);
|
* var type1Font = new Font("MyFontName", binaryFile, propertiesObject);
|
||||||
* type1Font.bind();
|
* type1Font.bind();
|
||||||
*/
|
*/
|
||||||
var Font = (function () {
|
var Font = (function Font() {
|
||||||
var constructor = function font_constructor(name, file, properties) {
|
var constructor = function font_constructor(name, file, properties) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.encoding = properties.encoding;
|
this.encoding = properties.encoding;
|
||||||
@ -543,7 +543,11 @@ var Font = (function () {
|
|||||||
for (var i = 0; i < length; i+=4)
|
for (var i = 0; i < length; i+=4)
|
||||||
checksum += int16([data[i], data[i+1], data[i+2], data[i+3]]);
|
checksum += int16([data[i], data[i+1], data[i+2], data[i+3]]);
|
||||||
|
|
||||||
var tableEntry = tag + string32(checksum) + string32(offset) + string32(length);
|
var tableEntry = tag +
|
||||||
|
string32(checksum) +
|
||||||
|
string32(offset) +
|
||||||
|
string32(length);
|
||||||
|
|
||||||
tableEntry = stringToArray(tableEntry);
|
tableEntry = stringToArray(tableEntry);
|
||||||
file.set(tableEntry, offsets.currentOffset);
|
file.set(tableEntry, offsets.currentOffset);
|
||||||
|
|
||||||
@ -783,7 +787,7 @@ var Font = (function () {
|
|||||||
(format == 6 && numTables == 1 && !properties.encoding.empty)) {
|
(format == 6 && numTables == 1 && !properties.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 charset here, it is not reliable");
|
TODO("Charset is not reliable, use somethin else");
|
||||||
var charset = properties.charset;
|
var charset = properties.charset;
|
||||||
var glyphs = [];
|
var glyphs = [];
|
||||||
for (var j = 0; j < charset.length; j++) {
|
for (var j = 0; j < charset.length; j++) {
|
||||||
@ -823,8 +827,9 @@ var Font = (function () {
|
|||||||
for (var j = 0; j < glyphs.length; j++)
|
for (var j = 0; j < glyphs.length; j++)
|
||||||
glyphs[j] = { unicode: glyphs[j] + firstCode };
|
glyphs[j] = { unicode: glyphs[j] + firstCode };
|
||||||
|
|
||||||
var ranges= getRanges(glyphs);
|
var ranges = getRanges(glyphs);
|
||||||
assert(ranges.length == 1, "Got " + ranges.length + " ranges in a dense array");
|
assert(ranges.length == 1,
|
||||||
|
"Got " + ranges.length + " ranges in a dense array");
|
||||||
|
|
||||||
var encoding = properties.encoding;
|
var encoding = properties.encoding;
|
||||||
var denseRange = ranges[0];
|
var denseRange = ranges[0];
|
||||||
@ -1041,7 +1046,7 @@ var Font = (function () {
|
|||||||
"cmap": createCMapTable(charstrings.slice()),
|
"cmap": createCMapTable(charstrings.slice()),
|
||||||
|
|
||||||
// Font header
|
// Font header
|
||||||
"head": (function() {
|
"head": (function convert_fields_head() {
|
||||||
return stringToArray(
|
return stringToArray(
|
||||||
"\x00\x01\x00\x00" + // Version number
|
"\x00\x01\x00\x00" + // Version number
|
||||||
"\x00\x00\x10\x00" + // fontRevision
|
"\x00\x00\x10\x00" + // fontRevision
|
||||||
@ -1063,7 +1068,7 @@ var Font = (function () {
|
|||||||
})(),
|
})(),
|
||||||
|
|
||||||
// Horizontal header
|
// Horizontal header
|
||||||
"hhea": (function() {
|
"hhea": (function convert_fields_hhea() {
|
||||||
return stringToArray(
|
return stringToArray(
|
||||||
"\x00\x01\x00\x00" + // Version number
|
"\x00\x01\x00\x00" + // Version number
|
||||||
string16(properties.ascent) + // Typographic Ascent
|
string16(properties.ascent) + // Typographic Ascent
|
||||||
@ -1085,7 +1090,7 @@ var Font = (function () {
|
|||||||
})(),
|
})(),
|
||||||
|
|
||||||
// Horizontal metrics
|
// Horizontal metrics
|
||||||
"hmtx": (function() {
|
"hmtx": (function convert_fields_hmtx() {
|
||||||
var hmtx = "\x00\x00\x00\x00"; // Fake .notdef
|
var hmtx = "\x00\x00\x00\x00"; // Fake .notdef
|
||||||
for (var i = 0; i < charstrings.length; i++) {
|
for (var i = 0; i < charstrings.length; i++) {
|
||||||
hmtx += string16(charstrings[i].width) + string16(0);
|
hmtx += string16(charstrings[i].width) + string16(0);
|
||||||
@ -1094,7 +1099,7 @@ var Font = (function () {
|
|||||||
})(),
|
})(),
|
||||||
|
|
||||||
// Maximum profile
|
// Maximum profile
|
||||||
"maxp": (function() {
|
"maxp": (function convert_fields_maxp() {
|
||||||
return stringToArray(
|
return stringToArray(
|
||||||
"\x00\x00\x50\x00" + // Version number
|
"\x00\x00\x50\x00" + // Version number
|
||||||
string16(charstrings.length + 1)); // Num of glyphs
|
string16(charstrings.length + 1)); // Num of glyphs
|
||||||
@ -1134,14 +1139,11 @@ var Font = (function () {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bindDOM: function font_bindDom(data) {
|
bindDOM: function font_bindDom(data) {
|
||||||
var fontName = this.name;
|
|
||||||
|
|
||||||
// Add the @font-face rule to the document
|
|
||||||
var url = "url(data:" + this.mimetype + ";base64," + window.btoa(data) + ");";
|
var url = "url(data:" + this.mimetype + ";base64," + window.btoa(data) + ");";
|
||||||
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + "}";
|
var rule = "@font-face { font-family:'" + this.name + "';src:" + url + "}";
|
||||||
|
|
||||||
var styleSheet = document.styleSheets[0];
|
var styleSheet = document.styleSheets[0];
|
||||||
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1154,7 +1156,7 @@ var Font = (function () {
|
|||||||
* program.
|
* program.
|
||||||
* Some of its logic depends on the Type2 charstrings structure.
|
* Some of its logic depends on the Type2 charstrings structure.
|
||||||
*/
|
*/
|
||||||
var Type1Parser = function() {
|
var Type1Parser = function Type1Parser() {
|
||||||
/*
|
/*
|
||||||
* Decrypt a Sequence of Ciphertext Bytes to Produce the Original Sequence
|
* Decrypt a Sequence of Ciphertext Bytes to Produce the Original Sequence
|
||||||
* of Plaintext Bytes. The function took a key as a parameter which can be
|
* of Plaintext Bytes. The function took a key as a parameter which can be
|
||||||
@ -1344,7 +1346,9 @@ var Type1Parser = function() {
|
|||||||
} else if (!command) {
|
} else if (!command) {
|
||||||
break;
|
break;
|
||||||
} else if (command == -1) {
|
} else if (command == -1) {
|
||||||
error("Support for Type1 command " + value + " (" + escape + ") is not implemented in charstring: " + charString);
|
error("Support for Type1 command " +
|
||||||
|
value + " (" + escape + ")" +
|
||||||
|
" is not implemented in charstring: " + charString);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = command;
|
value = command;
|
||||||
@ -1369,7 +1373,7 @@ var Type1Parser = function() {
|
|||||||
* Returns an object containing a Subrs array and a CharStrings array
|
* Returns an object containing a Subrs array and a CharStrings array
|
||||||
* extracted from and eexec encrypted block of data
|
* extracted from and eexec encrypted block of data
|
||||||
*/
|
*/
|
||||||
function readNumberArray(str, index) {
|
function readNumbers(str, index) {
|
||||||
var start = ++index;
|
var start = ++index;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
while (str[index++] != "]")
|
while (str[index++] != "]")
|
||||||
@ -1436,16 +1440,16 @@ var Type1Parser = function() {
|
|||||||
subrsSection = true;
|
subrsSection = true;
|
||||||
break;
|
break;
|
||||||
case "/StdHW":
|
case "/StdHW":
|
||||||
extracted.properties.stdHW = readNumberArray(eexecString, i + 2)[0];
|
extracted.properties.stdHW = readNumbers(eexecString, i + 2)[0];
|
||||||
break;
|
break;
|
||||||
case "/StdVW":
|
case "/StdVW":
|
||||||
extracted.properties.stdVW = readNumberArray(eexecString, i + 2)[0];
|
extracted.properties.stdVW = readNumbers(eexecString, i + 2)[0];
|
||||||
break;
|
break;
|
||||||
case "/StemSnapH":
|
case "/StemSnapH":
|
||||||
extracted.properties.stemSnapH = readNumberArray(eexecString, i + 2);
|
extracted.properties.stemSnapH = readNumbers(eexecString, i + 2);
|
||||||
break;
|
break;
|
||||||
case "/StemSnapV":
|
case "/StemSnapV":
|
||||||
extracted.properties.stemSnapV = readNumberArray(eexecString, i + 2);
|
extracted.properties.stemSnapV = readNumbers(eexecString, i + 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (c == "/") {
|
} else if (c == "/") {
|
||||||
@ -1475,7 +1479,7 @@ var Type1Parser = function() {
|
|||||||
if (c == " " || c == "\n") {
|
if (c == " " || c == "\n") {
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case "/FontMatrix":
|
case "/FontMatrix":
|
||||||
var matrix = readNumberArray(headerString, i + 1);
|
var matrix = readNumbers(headerString, i + 1);
|
||||||
|
|
||||||
// The FontMatrix is in unitPerEm, so make it pixels
|
// The FontMatrix is in unitPerEm, so make it pixels
|
||||||
for (var j = 0; j < matrix.length; j++)
|
for (var j = 0; j < matrix.length; j++)
|
||||||
@ -1502,66 +1506,70 @@ var Type1Parser = function() {
|
|||||||
* which itself embed Type2 charstrings.
|
* which itself embed Type2 charstrings.
|
||||||
*/
|
*/
|
||||||
var CFFStrings = [
|
var CFFStrings = [
|
||||||
".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand",
|
".notdef","space","exclam","quotedbl","numbersign","dollar","percent",
|
||||||
"quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period",
|
"ampersand","quoteright","parenleft","parenright","asterisk","plus","comma",
|
||||||
"slash","zero","one","two","three","four","five","six","seven","eight","nine",
|
"hyphen","period","slash","zero","one","two","three","four","five","six",
|
||||||
"colon","semicolon","less","equal","greater","question","at","A","B","C","D","E",
|
"seven","eight","nine","colon","semicolon","less","equal","greater",
|
||||||
"F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y",
|
"question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",
|
||||||
"Z","bracketleft","backslash","bracketright","asciicircum","underscore",
|
"P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash",
|
||||||
"quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q",
|
"bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e",
|
||||||
"r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde",
|
"f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x",
|
||||||
"exclamdown","cent","sterling","fraction","yen","florin","section","currency",
|
"y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent",
|
||||||
"quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright",
|
"sterling","fraction","yen","florin","section","currency","quotesingle",
|
||||||
"fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet",
|
"quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl",
|
||||||
|
"endash","dagger","daggerdbl","periodcentered","paragraph","bullet",
|
||||||
"quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis",
|
"quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis",
|
||||||
"perthousand","questiondown","grave","acute","circumflex","tilde","macron",
|
"perthousand","questiondown","grave","acute","circumflex","tilde","macron",
|
||||||
"breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron",
|
"breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek",
|
||||||
"emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi",
|
"caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine",
|
||||||
"lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark",
|
"ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior",
|
||||||
"Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree",
|
"logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn",
|
||||||
"thorn","threequarters","twosuperior","registered","minus","eth","multiply",
|
"onequarter","divide","brokenbar","degree","thorn","threequarters",
|
||||||
"threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring",
|
"twosuperior","registered","minus","eth","multiply","threesuperior",
|
||||||
|
"copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring",
|
||||||
"Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute",
|
"Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute",
|
||||||
"Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis",
|
"Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex",
|
||||||
"Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute",
|
"Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis",
|
||||||
"Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde",
|
"Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis",
|
||||||
"ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex",
|
"agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis",
|
||||||
"idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve",
|
"egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute",
|
||||||
"otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute",
|
"ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex",
|
||||||
"ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle",
|
"udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall",
|
||||||
"dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior",
|
"Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall",
|
||||||
"parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle",
|
"Acutesmall","parenleftsuperior","parenrightsuperior","206 ff",
|
||||||
"twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle",
|
"onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle",
|
||||||
"sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior",
|
"fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle",
|
||||||
"threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior",
|
"nineoldstyle","commasuperior","threequartersemdash","periodsuperior",
|
||||||
"centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior",
|
"questionsmall","asuperior","bsuperior","centsuperior","dsuperior",
|
||||||
"nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl",
|
"esuperior","isuperior","lsuperior","msuperior", "nsuperior","osuperior",
|
||||||
"parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior",
|
"rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior",
|
||||||
"Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall",
|
"parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall",
|
||||||
"Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall",
|
"Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall",
|
||||||
"Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall",
|
"Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall",
|
||||||
"Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall",
|
"Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall",
|
||||||
"centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall",
|
"Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall",
|
||||||
"Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash",
|
"exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall",
|
||||||
"hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall",
|
"Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall",
|
||||||
"oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds",
|
"figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall",
|
||||||
"zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior",
|
"questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths",
|
||||||
"eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior",
|
"onethird","twothirds","zerosuperior","foursuperior","fivesuperior",
|
||||||
"threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior",
|
"sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior",
|
||||||
"eightinferior","nineinferior","centinferior","dollarinferior","periodinferior",
|
"oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior",
|
||||||
"commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall",
|
"sixinferior","seveninferior","eightinferior","nineinferior","centinferior",
|
||||||
"Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall",
|
"dollarinferior","periodinferior","commainferior","Agravesmall",
|
||||||
"Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall",
|
"Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall",
|
||||||
"Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall",
|
"AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall",
|
||||||
"Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall",
|
"Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall",
|
||||||
"Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall",
|
"Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall",
|
||||||
|
"Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall",
|
||||||
|
"Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall",
|
||||||
"Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002",
|
"Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002",
|
||||||
"001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"
|
"001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"
|
||||||
];
|
];
|
||||||
|
|
||||||
var type1Parser = new Type1Parser();
|
var type1Parser = new Type1Parser();
|
||||||
|
|
||||||
var CFF = function(name, file, properties) {
|
var CFF = function CFF(name, file, properties) {
|
||||||
// Get the data block containing glyphs and subrs informations
|
// Get the data block containing glyphs and subrs informations
|
||||||
var length1 = file.dict.get("Length1");
|
var length1 = file.dict.get("Length1");
|
||||||
var length2 = file.dict.get("Length2");
|
var length2 = file.dict.get("Length2");
|
||||||
@ -1582,7 +1590,8 @@ var CFF = function(name, file, properties) {
|
|||||||
var subrs = this.getType2Subrs(data.subrs);
|
var subrs = this.getType2Subrs(data.subrs);
|
||||||
|
|
||||||
this.charstrings = charstrings;
|
this.charstrings = charstrings;
|
||||||
this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
|
this.data = this.wrap(name, type2Charstrings,
|
||||||
|
this.charstrings, subrs, properties);
|
||||||
};
|
};
|
||||||
|
|
||||||
CFF.prototype = {
|
CFF.prototype = {
|
||||||
@ -1643,7 +1652,7 @@ CFF.prototype = {
|
|||||||
var unicode = GlyphsUnicode[glyph.glyph];
|
var unicode = GlyphsUnicode[glyph.glyph];
|
||||||
if (!unicode) {
|
if (!unicode) {
|
||||||
if (glyph.glyph != ".notdef")
|
if (glyph.glyph != ".notdef")
|
||||||
warn(glyph + " does not have an entry in the glyphs unicode dictionary");
|
warn(glyph + " has no entry in the glyphs unicode dictionary");
|
||||||
} else {
|
} else {
|
||||||
charstrings.push({
|
charstrings.push({
|
||||||
glyph: glyph,
|
glyph: glyph,
|
||||||
@ -1666,7 +1675,8 @@ CFF.prototype = {
|
|||||||
var count = type1Charstrings.length;
|
var count = type1Charstrings.length;
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var charstring = type1Charstrings[i].charstring;
|
var charstring = type1Charstrings[i].charstring;
|
||||||
type2Charstrings.push(this.flattenCharstring(charstring.slice(), this.commandsMap));
|
var flate = this.flattenCharstring(charstring.slice(), this.commandsMap);
|
||||||
|
type2Charstrings.push(flate);
|
||||||
}
|
}
|
||||||
return type2Charstrings;
|
return type2Charstrings;
|
||||||
},
|
},
|
||||||
@ -1738,12 +1748,13 @@ CFF.prototype = {
|
|||||||
|
|
||||||
wrap: function wrap(name, glyphs, charstrings, subrs, properties) {
|
wrap: function wrap(name, glyphs, charstrings, subrs, properties) {
|
||||||
var fields = {
|
var fields = {
|
||||||
"header": "\x01\x00\x04\x04", // major version, minor version, header size, offset size
|
// major version, minor version, header size, offset size
|
||||||
|
"header": "\x01\x00\x04\x04",
|
||||||
|
|
||||||
"names": this.createCFFIndexHeader([name]),
|
"names": this.createCFFIndexHeader([name]),
|
||||||
|
|
||||||
"topDict": (function topDict(self) {
|
"topDict": (function topDict(self) {
|
||||||
return function() {
|
return function wrap_inner_topDict() {
|
||||||
var dict =
|
var dict =
|
||||||
"\x00\x01\x01\x01\x30" +
|
"\x00\x01\x01\x01\x30" +
|
||||||
"\xf8\x1b\x00" + // version
|
"\xf8\x1b\x00" + // version
|
||||||
@ -1795,9 +1806,9 @@ CFF.prototype = {
|
|||||||
var count = glyphs.length;
|
var count = glyphs.length;
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var index = CFFStrings.indexOf(charstrings[i].glyph.glyph);
|
var index = CFFStrings.indexOf(charstrings[i].glyph.glyph);
|
||||||
// Some characters like asterikmath && circlecopyrt are missing from the
|
// Some characters like asterikmath && circlecopyrt are missing from
|
||||||
// original strings, for the moment let's map them to .notdef and see
|
// the original strings, for the moment let's map them to .notdef and
|
||||||
// later if it cause any problems
|
// see later if it cause any problems
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
@ -1808,7 +1819,7 @@ CFF.prototype = {
|
|||||||
|
|
||||||
"charstrings": this.createCFFIndexHeader([[0x8B, 0x0E]].concat(glyphs), true),
|
"charstrings": this.createCFFIndexHeader([[0x8B, 0x0E]].concat(glyphs), true),
|
||||||
|
|
||||||
"private": (function(self) {
|
"private": (function wrap_private(self) {
|
||||||
var data =
|
var data =
|
||||||
"\x8b\x14" + // defaultWidth
|
"\x8b\x14" + // defaultWidth
|
||||||
"\x8b\x15" + // nominalWidth
|
"\x8b\x15" + // nominalWidth
|
||||||
|
Loading…
Reference in New Issue
Block a user