]> git.parisson.com Git - pdf.js.git/commitdiff
even more error checking for font translation
authorAndreas Gal <andreas.gal@gmail.com>
Fri, 17 Jun 2011 23:34:29 +0000 (16:34 -0700)
committerAndreas Gal <andreas.gal@gmail.com>
Fri, 17 Jun 2011 23:34:29 +0000 (16:34 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index d656db87bfda5eb2f4714c0a63f490072adf745a..56ab890176fa78bbc7aa0e04e61deca18db0dd0e 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1931,12 +1931,12 @@ var CanvasGraphics = (function() {
                 } else if (IsName(encoding)) {
                     var encoding = Encodings[encoding.name];
                     if (!encoding)
-                        error("Unknown encoding");
+                        error("Unknown font encoding");
 
                     var widths = xref.fetchIfRef(fontDict.get("Widths"));
                     var firstChar = xref.fetchIfRef(fontDict.get("FirstChar"));
                     assertWellFormed(IsArray(widths) && IsInteger(firstChar),
-                                     "invalid Widths or FirstChar");
+                                     "invalid font Widths or FirstChar");
                     var charset = [];
                     for (var j = 0; j < widths.length; j++) {
                         if (widths[j])
@@ -1945,11 +1945,16 @@ var CanvasGraphics = (function() {
                 }
             }
 
+            var subType = fontDict.get("Subtype");
+            var bbox = descriptor.get("FontBBox");
+            assertWellFormed(IsName(subType) && IsArray(bbox),
+                             "invalid font Subtype or FontBBox");
+
             var properties = {
-                type: fontDict.get("Subtype").name,
+                type: subType.name,
                 encoding: encodingMap,
                 charset: charset,
-                bbox: descriptor.get("FontBBox")
+                bbox: bbox
             };
 
             return {