]> git.parisson.com Git - pdf.js.git/commitdiff
Small changes
authorVivien Nicolas <21@vingtetun.org>
Mon, 13 Jun 2011 03:30:02 +0000 (05:30 +0200)
committerVivien Nicolas <21@vingtetun.org>
Mon, 13 Jun 2011 03:30:02 +0000 (05:30 +0200)
PDFFont.js
PDFFontUtils.js
cffStandardStrings.js
test.html

index 424c6721fbd2be2f1668332a3f22356742840036..7abd9aa65dabdc6128a16fab2780688c82ccb0d8 100644 (file)
@@ -41,6 +41,7 @@ var Font = function(aFontName, aFontFile, aFontType) {
     return;
   }
 
+  var start = Date.now();
   switch (aFontType) {
     case "Type1":
       // All Type1 font program should begin with the comment %!
@@ -64,6 +65,7 @@ var Font = function(aFontName, aFontFile, aFontType) {
       warn("Font " + aFontType + " is not supported");
       break;
   }
+  var end = Date.now();
 
   // Attach the font to the document
   this.bind();
@@ -417,7 +419,7 @@ Font.prototype = {
     for (var i = 0; i < offsets.currentOffset; i++)
       fontData.push(otf[i]);
 
-    writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".otf");
+    //writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".otf");
     return fontData;
   }
 };
@@ -477,8 +479,8 @@ var TrueType = function(aFontName, aFontFile) {
 var PSFonts = new Dict();
 
 
-var Stack = function() {
-  var innerStack = [];
+var Stack = function(aStackSize) {
+  var innerStack = new Array(aStackSize || 0);
 
   this.push = function(aOperand) {
     innerStack.push(aOperand);
@@ -695,7 +697,7 @@ var Type1Parser = function(aAsciiStream, aBinaryStream) {
    * operator returns one or more results, it does so by pushing them on the
    * operand stack.
    */
-   var operandStack = new Stack();
+   var operandStack = new Stack(40);
 
    // Flag indicating if the topmost operand of the operandStack is an array
    var operandIsArray = 0;
@@ -1156,7 +1158,7 @@ var CFF = function(aFontName, aFontFile) {
     this.font = PSFonts.get(fontName);
     this.data = this.convertToCFF(this.font);
     var end = Date.now();
-    log("Time to parse font is:" + (end - start));
+    //log("Time to parse font is:" + (end - start));
   }
 };
 
@@ -1392,7 +1394,7 @@ CFF.prototype = {
       248, 28, 1, // Notice
       248, 29, 2, // FullName
       248, 30, 3, // FamilyName
-      248, 31, 4, // Weight
+      248, 31, 4  // Weight
     ];
 
     for (var i = 0; i < fontBBox.length; i++)
index 36dc2b421a4fc3b6c5e5c6d989cbd2940b30d587..072dd48f1ce300ce4a9faf4817369a5ee6be76ec 100644 (file)
@@ -4,7 +4,7 @@
  *
  * So the code here is useful for dumping the data content of a .cff file in
  * order to investigate the similarity between a Type1 CharString and a Type2
- * CharString.
+ * CharString or to understand the structure of the CFF format.
  */
 
 
@@ -216,6 +216,14 @@ function readFontIndexData(aStream, aIsByte) {
 var Type2Parser = function(aFilePath) {
   var font = new Dict();
 
+  var xhr = new XMLHttpRequest();
+  xhr.open("GET", aFilePath, false);
+  xhr.mozResponseType = xhr.responseType = "arraybuffer";
+  xhr.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200;
+  xhr.send(null);
+  this.data = new Stream(xhr.mozResponseArrayBuffer || xhr.mozResponse ||
+                         xhr.responseArrayBuffer || xhr.response);
+
   // Turn on this flag for additional debugging logs
   var debug = false;
 
@@ -340,22 +348,16 @@ var Type2Parser = function(aFilePath) {
   }
 };
 
-
-var xhr = new XMLHttpRequest();
-xhr.open("GET", "titi.cff", false);
-xhr.mozResponseType = xhr.responseType = "arraybuffer";
-xhr.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200;
-xhr.send(null);
-var cffData = xhr.mozResponseArrayBuffer || xhr.mozResponse ||
-              xhr.responseArrayBuffer || xhr.response;
-var cff = new Type2Parser("titi.cff");
-//cff.parse(new Stream(cffData));
+/*
+var cff = new Type2Parser("test.cff");
+cff.parse();
+*/
 
 
 /**
  * Write to a file (works only on Firefox in privilege mode");
  */
- function writeToFile(aBytes, aFilePath) {
+function writeToFile(aBytes, aFilePath) {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   var Cc = Components.classes,
       Ci = Components.interfaces;
@@ -366,10 +368,10 @@ var cff = new Type2Parser("titi.cff");
                  .createInstance(Ci.nsIFileOutputStream);
   stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
 
- var bos = Cc["@mozilla.org/binaryoutputstream;1"]
-             .createInstance(Ci.nsIBinaryOutputStream);
 var bos = Cc["@mozilla.org/binaryoutputstream;1"]
+              .createInstance(Ci.nsIBinaryOutputStream);
   bos.setOutputStream(stream);
   bos.writeByteArray(aBytes, aBytes.length);
   stream.close();
- };
+};
 
index 585c1157ece699c8667f4f89f24af5b7352e65d6..8977cd8f2674e1135652d736e710ca8ef727f482 100644 (file)
@@ -686,3 +686,4 @@ var CFFDictPrivateDataMap = {
     operand: 0
   }
 };
+
index 5d0b15403312971595d3a12482e6b3e085ed048b..6b37f222f7d27f7662931fcbaaf99b1720e2d101 100644 (file)
--- a/test.html
+++ b/test.html
@@ -7,7 +7,6 @@
         <script type="text/javascript" src="test.js"></script>
         <script type="text/javascript" src="cffStandardStrings.js"></script>
         <script type="text/javascript" src="glyphlist.js"></script>
-        <script type="text/javascript" src="PDFFontUtils.js"></script>
         <script type="text/javascript" src="PDFFont.js"></script>
   </head>