From 81399ee0683377ac51d458ef7cffb0db76b48d4b Mon Sep 17 00:00:00 2001 From: mduan Date: Tue, 29 Jan 2013 16:16:54 -0500 Subject: [PATCH] Add support for GBK-EUC-H encoding for cid fonts --- src/fonts.js | 9 ++++++++- test/pdfs/issue2128.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/issue2128.pdf.link diff --git a/src/fonts.js b/src/fonts.js index 215105b78..1840b9e69 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -410,11 +410,14 @@ var CMapConverterList = { '90ms-RKSJ-H': sjisToUnicode, '90ms-RKSJ-V': sjisToUnicode, '90msp-RKSJ-H': sjisToUnicode, - '90msp-RKSJ-V': sjisToUnicode + '90msp-RKSJ-V': sjisToUnicode, + 'GBK-EUC-H': gbkToUnicode }; var decodeBytes; if (typeof TextDecoder !== 'undefined') { + // The encodings supported by TextDecoder can be found at: + // http://encoding.spec.whatwg.org/#concept-encoding-get decodeBytes = function(bytes, encoding) { return new TextDecoder(encoding).decode(bytes); }; @@ -444,6 +447,10 @@ function sjisToUnicode(str) { return decodeBytes(stringToBytes(str), 'shift_jis'); } +function gbkToUnicode(str) { + return decodeBytes(stringToBytes(str), 'gbk'); +} + // Some characters, e.g. copyrightserif, mapped to the private use area and // might not be displayed using standard fonts. Mapping/hacking well-known chars // to the similar equivalents in the normal characters range. diff --git a/test/pdfs/issue2128.pdf.link b/test/pdfs/issue2128.pdf.link new file mode 100644 index 000000000..0a487bab0 --- /dev/null +++ b/test/pdfs/issue2128.pdf.link @@ -0,0 +1 @@ +http://www.bookcool.com/pdf/6/ts006006.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 319e2ab60..a5ed76abe 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -44,6 +44,14 @@ "rounds": 1, "type": "eq" }, + { "id": "issue2128", + "file": "pdfs/issue2128.pdf", + "md5": "b3f4d9ed3c41e1f1768264a3f8b93aad", + "link": true, + "pageLimit": 2, + "rounds": 1, + "type": "eq" + }, { "id": "pdfspec-load", "file": "pdfs/pdf.pdf", "md5": "dbdb23c939d2be09b43126c3c56060c7",