]> git.parisson.com Git - pdf.js.git/commitdiff
Added myself to the license (yay!)
authorAdil Allawi <adil@diwan.com>
Fri, 16 Sep 2011 22:55:06 +0000 (23:55 +0100)
committerAdil Allawi <adil@diwan.com>
Fri, 16 Sep 2011 22:55:06 +0000 (23:55 +0100)
Tweaked according to comments in pull request #482

LICENSE
fonts.js

diff --git a/LICENSE b/LICENSE
index d96b927a36ecf1cc2d1b7458f5a2f29ccbcf0347..f8a848205708f8457cbf0745d8b5aebdf4c60e43 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -8,6 +8,7 @@
                   Justin D'Arcangelo <justindarc@gmail.com>
                   Yury Delendik
                   Kalervo Kujala
+                  Adil Allawi <@ironymark>
 
     Permission is hereby granted, free of charge, to any person obtaining a
     copy of this software and associated documentation files (the "Software"),
index fd7a23bd30a777458d0ca8f6089216919953ca52..4f95d16f035784a2ddf0aa2cec16ef0836c16876 100644 (file)
--- a/fonts.js
+++ b/fonts.js
@@ -670,7 +670,9 @@ var Font = (function Font() {
                          format314);
   };
 
-  function createOS2Table(properties) {
+  function createOS2Table(properties, override) {
+    var override = override || {};
+
     var ulUnicodeRange1 = 0;
     var ulUnicodeRange2 = 0;
     var ulUnicodeRange3 = 0;
@@ -701,22 +703,19 @@ var Font = (function Font() {
       }
     }
 
-    var openTypeUnitsPerEm = (typeof (properties.openTypeUnitsPerEm) == 'undefined') ? kPDFGlyphSpaceUnits : properties.openTypeUnitsPerEm;
-    var typoAscent = properties.ascent;
-    var typoDescent = properties.descent;
-    var winAscent = typoAscent;
-    var winDescent = -typoDescent;
-
-    // if the font already has ascent and descent information then use these values
-    if (typeof (properties.openTypeAscent) != 'undefined') {
-      typoAscent = properties.openTypeAscent;
-      typoDescent = properties.openTypeDescent;
-      winAscent = properties.openTypeYMax;
-      winDescent = -properties.openTypeYMin;
-    } else if (openTypeUnitsPerEm != kPDFGlyphSpaceUnits) {
+    var unitsPerEm = override.unitsPerEm || kPDFGlyphSpaceUnits;
+    var typoAscent = override.ascent || properties.ascent;
+    var typoDescent = override.descent || properties.descent;
+    var winAscent = override.yMax || typoAscent;
+    var winDescent = -override.yMin || -typoDescent;
+
+    // if there is a units per em value but no other override then scale the calculated ascent
+    if (unitsPerEm != kPDFGlyphSpaceUnits && 'undefined' == typeof(override.ascent)) {
       // if the font units differ to the PDF glyph space units then scale up the values
-      typoAscent = Math.round(typoAscent * openTypeUnitsPerEm / kPDFGlyphSpaceUnits);
-      typoDescent = Math.round(typoDescent * openTypeUnitsPerEm / kPDFGlyphSpaceUnits);
+      typoAscent = Math.round(typoAscent * unitsPerEm / kPDFGlyphSpaceUnits);
+      typoDescent = Math.round(typoDescent * unitsPerEm / kPDFGlyphSpaceUnits);
+      winAscent = typoAscent;
+      winDescent = -typoDescent;
     }
 
     return '\x00\x03' + // version
@@ -1072,22 +1071,23 @@ var Font = (function Font() {
         virtualOffset: numTables * (4 * 4)
       };
 
-      //extract some more font properties from the OpenType head and hhea tables
-      properties.openTypeUnitsPerEm = int16([head.data[18], head.data[19]]);
-      properties.openTypeYMax = int16([head.data[42], head.data[43]]);
-      properties.openTypeYMin = int16([head.data[38], head.data[39]]) - 0x10000;   //always negative
-      properties.openTypeAscent =  int16([hhea.data[4], hhea.data[5]]);
-      properties.openTypeDescent =  int16([hhea.data[6], hhea.data[7]]) - 0x10000;   //always negative
-
-
       // The new numbers of tables will be the last one plus the num
       // of missing tables
       createOpenTypeHeader(header.version, ttf, numTables);
 
       if (requiredTables.indexOf('OS/2') != -1) {
+        //extract some more font properties from the OpenType head and hhea tables
+        var override = {
+          unitsPerEm: int16([head.data[18], head.data[19]]),
+          yMax: int16([head.data[42], head.data[43]]),
+          yMin: int16([head.data[38], head.data[39]]) - 0x10000, //always negative
+          ascent: int16([hhea.data[4], hhea.data[5]]),
+          descent: int16([hhea.data[6], hhea.data[7]]) - 0x10000 //always negative
+        }
+
         tables.push({
           tag: 'OS/2',
-          data: stringToArray(createOS2Table(properties))
+          data: stringToArray(createOS2Table(properties, override))
         });
       }