diff options
author | Nicolas Pena <npm@chromium.org> | 2017-05-17 14:45:52 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-17 19:32:12 +0000 |
commit | b48912f4f3c428c8b71bbb714faa03cb843d40b0 (patch) | |
tree | da310cd1c2bb33ab0d4cc08917b8ec2d430a16c9 | |
parent | 17f4e0268b31f2f75a01567b83dbb763680344e1 (diff) | |
download | pdfium-b48912f4f3c428c8b71bbb714faa03cb843d40b0.tar.xz |
Add some missing keywords in ToUnicode
Bug: pdfium:667
Change-Id: I8c3d07d2c533e6dd2a98099673b136c587c37a98
Reviewed-on: https://pdfium-review.googlesource.com/5630
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
-rw-r--r-- | fpdfsdk/fpdfedittext.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp index c2f2df9778..a14f54515f 100644 --- a/fpdfsdk/fpdfedittext.cpp +++ b/fpdfsdk/fpdfedittext.cpp @@ -89,7 +89,14 @@ const char ToUnicodeStart[] = "/CMapName /Adobe-Identity-H def\n" "CMapType 2 def\n" "1 begincodespacerange\n" - "<0000> <FFFFF>\n"; + "<0000> <FFFFF>\n" + "endcodespacerange\n"; + +const char ToUnicodeEnd[] = + "endcmap\n" + "CMapName currentdict /CMap defineresource pop\n" + "end\n" + "end\n"; void AddCharcode(CFX_ByteTextBuf* pBuffer, uint32_t number) { ASSERT(number <= 0xFFFF); @@ -115,8 +122,6 @@ void AddUnicode(CFX_ByteTextBuf* pBuffer, uint32_t unicode) { // Loads the charcode to unicode mapping into a stream CPDF_Stream* LoadUnicode(CPDF_Document* pDoc, const std::map<uint32_t, uint32_t>& to_unicode) { - CFX_ByteTextBuf buffer; - buffer << ToUnicodeStart; // A map charcode->unicode std::map<uint32_t, uint32_t> char_to_uni; // A map <char_start, char_end> to vector v of unicode characters of size (end @@ -179,6 +184,8 @@ CPDF_Stream* LoadUnicode(CPDF_Document* pDoc, } map_range[std::make_pair(firstCharcode, curCharcode)] = firstUnicode; } + CFX_ByteTextBuf buffer; + buffer << ToUnicodeStart; // Add maps to buffer buffer << static_cast<uint32_t>(char_to_uni.size()) << " beginbfchar\n"; for (const auto& iter : char_to_uni) { @@ -214,6 +221,8 @@ CPDF_Stream* LoadUnicode(CPDF_Document* pDoc, AddUnicode(&buffer, iter.second); buffer << "\n"; } + buffer << "endbfrange\n"; + buffer << ToUnicodeEnd; // TODO(npm): Encrypt / Compress? uint32_t bufferSize = buffer.GetSize(); auto pDict = pdfium::MakeUnique<CPDF_Dictionary>(); |