]> git.parisson.com Git - pdf.js.git/commitdiff
Start displaying TrueType fonts
authorVivien Nicolas <21@vingtetun.org>
Tue, 21 Jun 2011 19:11:59 +0000 (21:11 +0200)
committerVivien Nicolas <21@vingtetun.org>
Tue, 21 Jun 2011 19:11:59 +0000 (21:11 +0200)
fonts.js
pdf.js

index ad3d4fd35b3415334fdf8d312a28c7f12c96b12b..80a9f4bc2c2cfe8d7fc27dfffaa88dc07e77dfa3 100644 (file)
--- a/fonts.js
+++ b/fonts.js
@@ -103,7 +103,7 @@ var Font = (function () {
 
     // 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 || properties.type == "TrueType" || kDisableFonts) {
+    if (properties.ignore || kDisableFonts) {
       Fonts[name] = {
         data: file,
         loading: false,
@@ -368,11 +368,11 @@ var Font = (function () {
         var length = FontsUtils.bytesToInteger(file.getBytes(4));
 
         // Read the table associated data
-        var currentPosition = file.pos;
-        file.pos = file.start + offset;
-
+        var previousPosition = file.pos;
+        file.pos = file.start ? file.start : 0;
+        file.skip(offset);
         var data = file.getBytes(length);
-        file.pos = currentPosition;
+        file.pos = previousPosition;
 
         return {
           tag: tag,
diff --git a/pdf.js b/pdf.js
index 4db4ef06f785953877f813ca08a744c4e5f94415..8268f167371fb4ffad208c054e09f69293c3a0d9 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -2199,8 +2199,13 @@ var CanvasGraphics = (function() {
                     var tokens = [];
                     var token = "";
 
-                    var buffer = cmapObj.ensureBuffer ? cmapObj.ensureBuffer() : cmapObj;
-                    var cmap = cmapObj.getBytes(buffer.byteLength);
+                    var length = cmapObj.length;
+                    if (cmapObj instanceof FlateStream) {
+                      cmapObj.readBlock();
+                      length = cmapObj.bufferLength;
+                    }
+
+                    var cmap = cmapObj.getBytes(length);
                     for (var i =0; i < cmap.length; i++) {
                       var byte = cmap[i];
                       if (byte == 0x20 || byte == 0x0A || byte == 0x3C || byte == 0x3E) {