]> git.parisson.com Git - pdf.js.git/commitdiff
Remap all glyphs to Unicode Private Use Area if it is possible otherwise only remap...
authorAdil Allawi <adil@diwan.com>
Wed, 5 Oct 2011 07:42:13 +0000 (08:42 +0100)
committerAdil Allawi <adil@diwan.com>
Wed, 5 Oct 2011 07:42:13 +0000 (08:42 +0100)
fonts.js

index 83e0771b4e7bc55ed20c5c655b3e688dac4cb273..b464d346b133c46676e1c0463b9d4acf79f3981c 100644 (file)
--- a/fonts.js
+++ b/fonts.js
@@ -13,9 +13,6 @@ var kMaxWaitForFontFace = 1000;
 var kCmapGlyphOffset = 0xE000;
 var kSizeOfGlyphArea = 0x1900;
 
-//start of CJK block
-var kUnicodeCJKStart = 0x2E80;
-
 // PDF Glyph Space Units are one Thousandth of a TextSpace Unit
 // except for Type 3 fonts
 var kPDFGlyphSpaceUnits = 1000;
@@ -1220,21 +1217,23 @@ var Font = (function Font() {
         // offsetting glyphs to avoid problematic unicode ranges should only be
         // done for fonts with a medium-sized glyph count otherwise we could
         // overflow the glyph range or overwrite existing glyph positions
-        var cmapGlyphOffset = numGlyphs < kSizeOfGlyphArea ? kCmapGlyphOffset : 0;
+        var canRemapAllGlyphs = numGlyphs < kSizeOfGlyphArea;
 
         for (i in encoding) {
           if (encoding.hasOwnProperty(i)) {
             var unicode = encoding[i].unicode;
-            if (unicode <= 0x1f || (unicode >= 127 && unicode <= kSizeOfGlyphArea))
-              encoding[i].unicode = unicode += cmapGlyphOffset;
+            if (canRemapAllGlyphs || unicode <= 0x1f ||
+                (unicode >= 127 && unicode <= 255))
+              encoding[i].unicode += kCmapGlyphOffset;
           }
         }
 
         var glyphs = [];
         for (i = 1; i < numGlyphs; i++) {
           glyphs.push({
-            unicode: i <= 0x1f || (i >= 127 && i < kSizeOfGlyphArea) ?
-              i + cmapGlyphOffset : i
+            unicode: canRemapAllGlyphs ||
+                     i <= 0x1f || (i >= 127 && i < kSizeOfGlyphArea) ?
+              i + kCmapGlyphOffset : i
           });
         }
         cmap.data = createCMapTable(glyphs);