]> git.parisson.com Git - pdf.js.git/commitdiff
BaseFont and misc fonts fixes
authornotmasteryet <async.processingjs@yahoo.com>
Sun, 14 Aug 2011 13:40:22 +0000 (08:40 -0500)
committernotmasteryet <async.processingjs@yahoo.com>
Sun, 14 Aug 2011 13:40:22 +0000 (08:40 -0500)
fonts.js
pdf.js
test/pdfs/ecma262.pdf.link [new file with mode: 0644]
test/test_manifest.json

index 4f1c7ef664d467d48de99442a0139409b0096531..e994526d76abe5bf6f710cd065571b16fba1bea9 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -7,7 +7,7 @@ var isWorker = (typeof window == 'undefined');
 /**
  * Maximum file size of the font.
  */
-var kMaxFontFileSize = 200000;
+var kMaxFontFileSize = 300000;
 
 /**
  * Maximum time to wait for a font to be loaded by font-face rules.
@@ -83,7 +83,7 @@ var FontMeasure = (function FontMeasure() {
       var bold = font.bold ? 'bold' : 'normal';
       var italic = font.italic ? 'italic' : 'normal';
       size *= kScalePrecision;
-      var rule = bold + ' ' + italic + ' ' + size + 'px "' + name + '"';
+      var rule = italic + ' ' + bold + ' ' + size + 'px "' + name + '"';
       ctx.font = rule;
     },
     measureText: function fonts_measureText(text) {
@@ -395,17 +395,23 @@ var Font = (function Font() {
     // If the font is to be ignored, register it like an already loaded font
     // to avoid the cost of waiting for it be be loaded by the platform.
     if (properties.ignore) {
-      this.loadedName = 'Arial';
+      this.loadedName = 'sans-serif';
       this.loading = false;
       return;
     }
 
     if (!file) {
-      var fontName = stdFontMap[name];
+      // The file data is not specified. Trying to mingle the font name
+      // to be used with the canvas.font.
+      var fontName = stdFontMap[name] || name.replace('_', '-');
       this.bold = (fontName.indexOf('Bold') != -1);
-      this.italic = (fontName.indexOf('Oblique') != -1);
+      this.italic = (fontName.indexOf('Oblique') != -1) ||
+                    (fontName.indexOf('Italic') != -1);
       this.loadedName = fontName.split('-')[0];
       this.loading = false;
+      this.charsToUnicode = function(s) {
+        return s;
+      };
       return;
     }
 
diff --git a/pdf.js b/pdf.js
index fbe9b7717e5308c06c10618ce92bee396c63d909..e6a0d6713c400f407ed173def9b4ac75b4bb2ab7 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3758,8 +3758,17 @@ var PartialEvaluator = (function() {
         fd = fontDict.get('FontDescriptor');
       }
 
-      if (!fd)
-        return null;
+      if (!fd) {
+        var baseFontName = fontDict.get('BaseFont');
+        if (!IsName(baseFontName))
+          return null;
+        // Using base font name as a font name.
+        return {
+          name: baseFontName.name.replace(/[\+,\-]/g, '_'),
+          fontDict: fontDict,
+          properties: {}
+        };
+      }
 
       var descriptor = xref.fetch(fd);
 
@@ -4298,7 +4307,7 @@ var CanvasGraphics = (function() {
 
         var bold = fontObj.bold ? 'bold' : 'normal';
         var italic = fontObj.italic ? 'italic' : 'normal';
-        var rule = bold + ' ' + italic + ' ' + size + 'px "' + name + '"';
+        var rule = italic + ' ' + bold + ' ' + size + 'px "' + name + '"';
         this.ctx.font = rule;
       }
     },
diff --git a/test/pdfs/ecma262.pdf.link b/test/pdfs/ecma262.pdf.link
new file mode 100644 (file)
index 0000000..9aae675
--- /dev/null
@@ -0,0 +1 @@
+http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
index 8b0e2b7195e6cf77d28596d2a121cf100513173b..d40e53277f00f0a005e6aa27b23c1c18138ab5e6 100644 (file)
        "file": "pdfs/rotation.pdf",
        "rounds": 1,
        "type": "load"
+    },
+    {  "id": "ecma262-pdf",
+       "file": "pdfs/ecma262.pdf",
+       "link": true,
+       "rounds": 1,
+       "type": "load"
     }
 ]