From 0df411a3da2e373ad76f960fd706736ef478e7ae Mon Sep 17 00:00:00 2001
From: vyv03354 <VYV03354@nifty.ne.jp>
Date: Thu, 24 Jan 2013 01:15:02 +0900
Subject: [PATCH] Fixes non-Japanese characters spacing

---
 src/fonts.js                     |  12 ++++++++----
 test/pdfs/.gitignore             |   1 +
 test/pdfs/noembed-identity-2.pdf | Bin 0 -> 2123 bytes
 test/test_manifest.json          |   6 ++++++
 4 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100644 test/pdfs/noembed-identity-2.pdf

diff --git a/src/fonts.js b/src/fonts.js
index 928c63b0a..48dc7c941 100644
--- a/src/fonts.js
+++ b/src/fonts.js
@@ -4171,12 +4171,16 @@ var Font = (function FontClosure() {
       }
 
       var cidEncoding = properties.cidEncoding;
-      if (cidEncoding && cidEncoding.indexOf('Identity-') !== 0) {
+      if (!cidEncoding) {
+        return;
+      }
+      if (cidEncoding.indexOf('Identity-') !== 0) {
         // input is already Unicode for non-Identity CMap encodings.
-        // However, Unicode-to-CID conversion is needed
-        // regardless of the CMap encoding. So we can't reset
-        // unicodeToCID.
         this.cidToUnicode = [];
+      } else {
+        // We don't have to do reverse conversions if the string is
+        // already CID.
+        this.unicodeToCID = [];
       }
     },
 
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index dd9335f3a..9e0c0ffd5 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -40,6 +40,7 @@
 !mixedfonts.pdf
 !shading_extend.pdf
 !noembed-identity.pdf
+!noembed-identity-2.pdf
 !noembed-jis7.pdf
 !noembed-eucjp.pdf
 !noembed-sjis.pdf
diff --git a/test/pdfs/noembed-identity-2.pdf b/test/pdfs/noembed-identity-2.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..5bc89bea6236d943f8ac899a397c4618a4018f1f
GIT binary patch
literal 2123
zcmaJ?TTkOg6z+4R{D<>`#6D2Z)iYBeBrZ#rZMTa^R34%{m}CfE5j(Pn73r_<cg7F}
zc3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Sg#%unk-=Z^WI5W>tzWg*fJ2Dq%Aaf?Oj(*
zi*LuVK;sD|?nH^nb)YObN|+O#=>4tAdv+JzpRrk`2efe(!KR4SdOSLtzOGXY^Yk9y
z0N(o&4T13zG+o1;HfKU8C4|vJSc4x%(1JG1%jXlCexr}m{JnZL{rc&8?&AG;1fv4~
zcMp};YD;|c@?erPMa_;U(TzXwO6*yF_T-fPQBGs3-^&^F`+FXvc*m0l^YfnPun>2=
x)K&Fk?1t}tUcsEW8!B$vmRD=0C-py(S1FgIPgR$OOh~W&cyw^^@$2Py^e+*z2<-p>

literal 0
HcmV?d00001

diff --git a/test/test_manifest.json b/test/test_manifest.json
index 8fbe6531f..9a4f938ce 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -823,6 +823,12 @@
       "rounds": 1,
       "type": "eq"
     },
+    {  "id": "noembed-identity-2",
+      "file": "pdfs/noembed-identity-2.pdf",
+      "md5": "5549571a910814a9c53a1761b27fd028",
+      "rounds": 1,
+      "type": "eq"
+    },
     {  "id": "noembed-jis7",
       "file": "pdfs/noembed-jis7.pdf",
       "md5": "a0f6cf5a830f23d0c35994a6aaf92b3d",