[Pkg-javascript-commits] [pdf.js] 56/119: Move the checks for problematic Unicode locations from |adjustMapping| to a separate helper function

David Prévot taffit at moszumanska.debian.org
Wed May 13 21:27:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit a54ec673c5338e44a159f1acbf87d07c898a4aad
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Apr 9 12:56:29 2015 +0200

    Move the checks for problematic Unicode locations from |adjustMapping| to a separate helper function
---
 src/core/fonts.js | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index a2efa65..57d1328 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -2656,6 +2656,31 @@ var Font = (function FontClosure() {
   }
 
   /**
+   * Helper function for |adjustMapping|.
+   * @return {boolean}
+   */
+  function isProblematicUnicodeLocation(code) {
+    if (code <= 0x1F) { // Control chars
+      return true;
+    }
+    if (code >= 0x80 && code <= 0x9F) { // Control chars
+      return true;
+    }
+    if (code >= 0xFFF0 && code <= 0xFFFF) { // Specials Unicode block
+      return true;
+    }
+    switch (code) {
+      case 0x7F: // Control char
+      case 0xA0: // Non breaking space
+      case 0xAD: // Soft hyphen
+      case 0x0E33: // Thai character SARA AM
+      case 0x25CC: // Dotted circle (combining mark)
+        return true;
+    }
+    return false;
+  }
+
+  /**
    * Rebuilds the char code to glyph ID map by trying to replace the char codes
    * with their unicode value. It also moves char codes that are in known
    * problematic locations.
@@ -2694,15 +2719,7 @@ var Font = (function FontClosure() {
       // characters probably aren't in the correct position (fixes an issue
       // with firefox and thuluthfont).
       if ((usedFontCharCodes[fontCharCode] !== undefined ||
-           fontCharCode <= 0x1f || // Control chars
-           fontCharCode === 0x7F || // Control char
-           fontCharCode === 0xAD || // Soft hyphen
-           fontCharCode === 0xA0 || // Non breaking space
-           fontCharCode === 0x0E33 || // Thai character SARA AM 
-           fontCharCode === 0x25CC || // Dotted circle (combining mark)
-           (fontCharCode >= 0x80 && fontCharCode <= 0x9F) || // Control chars
-           // Prevent drawing characters in the specials unicode block.
-           (fontCharCode >= 0xFFF0 && fontCharCode <= 0xFFFF) ||
+           isProblematicUnicodeLocation(fontCharCode) ||
            (isSymbolic && isIdentityUnicode)) &&
           nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left.
         // Loop to try and find a free spot in the private use area.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list