Remove some useless JS function calls

This commit is contained in:
Vivien Nicolas 2011-06-16 01:09:17 +02:00
parent d565193cbd
commit c0ef98a9da

View File

@ -1096,9 +1096,9 @@ var Type1Parser = function() {
token = ""; token = "";
glyph = ""; glyph = "";
while ((c = eexecString[++i]) != 0x20 && i < count) while ((c = eexecString[++i]) != 0x20)
glyph += String.fromCharCode(c); glyph += String.fromCharCode(c);
} else if (c == 0x2F && eexecString[i+1] == 0x53 && !inGlyphs && !inSubrs) { } else if (!inSubrs && !inGlyphs && c == 0x2F && eexecString[i+1] == 0x53) {
while ((c = eexecString[++i]) != 0x20) {}; while ((c = eexecString[++i]) != 0x20) {};
inSubrs = true; inSubrs = true;
} else if (c == 0x20) { } else if (c == 0x20) {
@ -1127,7 +1127,9 @@ var Type1Parser = function() {
* chapter 8. * chapter 8.
*/ */
this.flattenCharstring = function(aCharstring, aSubrs) { this.flattenCharstring = function(aCharstring, aSubrs) {
var operandStackIndex = 0;
operandStack.clear(); operandStack.clear();
executionStack.clear(); executionStack.clear();
executionStack.push(aCharstring.slice()); executionStack.push(aCharstring.slice());
@ -1135,48 +1137,13 @@ var Type1Parser = function() {
var lastPoint = 0; var lastPoint = 0;
while (true) { while (true) {
var obj = nextInStack(); var obj = nextInStack();
if (IsBool(obj) || IsInt(obj) || IsNum(obj)) { if (IsInt(obj) || IsBool(obj)) {
dump("Value: " + obj);
operandStack.push(obj); operandStack.push(obj);
} else if (IsString(obj)) { } else {
dump("String: " + obj);
switch (obj) { switch (obj) {
case "hsbw":
var charWidthVector = operandStack.pop();
var leftSidebearing = operandStack.pop();
operandStack.push(charWidthVector);
if (leftSidebearing) {
operandStack.push(leftSidebearing);
operandStack.push("hmoveto");
}
break;
case "div":
var num2 = operandStack.pop();
var num1 = operandStack.pop();
operandStack.push(num2 / num1);
break;
case "setcurrentpoint":
case "dotsection":
case "seac":
case "sbw":
error(obj + " parsing is not implemented (yet)");
break;
case "closepath":
case "return":
break;
case "vstem3": case "vstem3":
case "vstem":
operandStack.push("vstem");
break;
case "hstem":
case "hstem3": case "hstem3":
operandStack.push("hstem"); operandStack.push(obj.slice(0, 5));
break; break;
case "callsubr": case "callsubr":
@ -1196,12 +1163,40 @@ var Type1Parser = function() {
operandStack.push("callothersubr"); operandStack.push("callothersubr");
break; break;
case "div":
var num2 = operandStack.pop();
var num1 = operandStack.pop();
operandStack.push(num2 / num1);
break;
case "pop":
operandStack.pop();
break;
case "closepath":
case "return":
break;
case "hsbw":
var charWidthVector = operandStack.pop();
var leftSidebearing = operandStack.pop();
operandStack.push(charWidthVector);
if (leftSidebearing) {
operandStack.push(leftSidebearing);
operandStack.push("hmoveto");
}
break;
case "endchar": case "endchar":
operandStack.push("endchar"); operandStack.push("endchar");
return operandStack.clone(); return operandStack.clone();
case "pop": case "setcurrentpoint":
operandStack.pop(); case "dotsection":
case "seac":
case "sbw":
error(obj + " parsing is not implemented (yet)");
break; break;
default: default:
@ -1214,8 +1209,6 @@ var Type1Parser = function() {
}; };
var CFF = function(aFontName, aFontBBox, aFontFile) { var CFF = function(aFontName, aFontBBox, aFontFile) {
var start = Date.now();
// Get the data block containing glyphs and subrs informations // Get the data block containing glyphs and subrs informations
var length1 = aFontFile.dict.get("Length1"); var length1 = aFontFile.dict.get("Length1");
var length2 = aFontFile.dict.get("Length2"); var length2 = aFontFile.dict.get("Length2");
@ -1223,6 +1216,7 @@ var CFF = function(aFontName, aFontBBox, aFontFile) {
var eexecBlock = aFontFile.getBytes(length2); var eexecBlock = aFontFile.getBytes(length2);
// Extract informations from it // Extract informations from it
var start = Date.now();
var parser = new Type1Parser(); var parser = new Type1Parser();
var fontInfo = parser.extractFontInfo(eexecBlock); var fontInfo = parser.extractFontInfo(eexecBlock);
fontInfo.name = aFontName; fontInfo.name = aFontName;