From 84be3a3cfec5107aac9a58ea00b58b733d393c7d Mon Sep 17 00:00:00 2001 From: npm Date: Thu, 15 Sep 2016 13:27:21 -0700 Subject: Use ToUnicode mapping even when unicode is 0. CPDF_Font::UnicodeFromCharcode returns 0 only if ToUnicode map maps the charcode to 0. CPDF_SimpleFont::UnicodeFromCharcode and CPDF_CID_Font:: UnicodeFromCharCode return 0 only if the call to CPDF_Font returns 0. In other cases, these methods return an empty string. So when processing text, a 0 return from the method should not be replaced with the charcode. BUG=pdfium:583 Review-Url: https://codereview.chromium.org/2342073002 --- fpdfsdk/fpdftext_embeddertest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdftext_embeddertest.cpp b/fpdfsdk/fpdftext_embeddertest.cpp index 3070c30771..957e813f64 100644 --- a/fpdfsdk/fpdftext_embeddertest.cpp +++ b/fpdfsdk/fpdftext_embeddertest.cpp @@ -388,3 +388,18 @@ TEST_F(FPDFTextEmbeddertest, GetFontSize) { FPDFText_ClosePage(textpage); UnloadPage(page); } + +TEST_F(FPDFTextEmbeddertest, ToUnicode) { + EXPECT_TRUE(OpenDocument("bug_583.pdf")); + FPDF_PAGE page = LoadPage(0); + EXPECT_TRUE(page); + + FPDF_TEXTPAGE textpage = FPDFText_LoadPage(page); + EXPECT_TRUE(textpage); + + ASSERT_EQ(1, FPDFText_CountChars(textpage)); + EXPECT_EQ(static_cast(0), FPDFText_GetUnicode(textpage, 0)); + + FPDFText_ClosePage(textpage); + UnloadPage(page); +} -- cgit v1.2.3