diff options
author | Ryan Wiley <wileyrr@gmail.com> | 2017-08-10 14:04:13 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-10 22:17:58 +0000 |
commit | f1c72de7794b309c9691c0b02b6100cdde042015 (patch) | |
tree | 328e9e4a1f2577eaa3bb14acf07fb98f44d0c7bc /core | |
parent | f3d8573dc0191437be7339e9d5098bfd3e55aafb (diff) | |
download | pdfium-f1c72de7794b309c9691c0b02b6100cdde042015.tar.xz |
Move graphic state operations outside BT/ET operations
Bug: pdfium:857
Change-Id: Ic1fb12459cad79b45466df10a24fe6743377ae14
Reviewed-on: https://pdfium-review.googlesource.com/10612
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 18bcbf909d..9153bf4cea 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -352,6 +352,7 @@ void CPDF_PageContentGenerator::ProcessDefaultGraphics( // Tj sets the actual text, <####...> is used when specifying charcodes. void CPDF_PageContentGenerator::ProcessText(std::ostringstream* buf, CPDF_TextObject* pTextObj) { + ProcessGraphics(buf, pTextObj); *buf << "BT " << pTextObj->GetTextMatrix() << " Tm "; CPDF_Font* pFont = pTextObj->GetFont(); if (!pFont) @@ -391,7 +392,6 @@ void CPDF_PageContentGenerator::ProcessText(std::ostringstream* buf, if (charcode != CPDF_Font::kInvalidCharCode) pFont->AppendChar(&text, charcode); } - ProcessGraphics(buf, pTextObj); *buf << PDF_EncodeString(text, true) << " Tj ET"; *buf << " Q\n"; } diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index e9676b1115..1f4d821dae 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -195,11 +195,12 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) { textString.Mid(firstResourceAt, secondResourceAt - firstResourceAt); CFX_ByteString lastString = textString.Right(textString.GetLength() - secondResourceAt); - CFX_ByteString compareString1 = "BT 1 0 0 1 100 100 Tm /"; + // q and Q must be outside the BT .. ET operations + CFX_ByteString compareString1 = + "q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /"; // Color RGB values used are integers divided by 255. - CFX_ByteString compareString2 = - " 10 Tf q 0.501961 0.701961 0.34902 rg 1 0.901961 0 RG /"; - CFX_ByteString compareString3 = " gs <48656C6C6F20576F726C64> Tj ET Q\n"; + CFX_ByteString compareString2 = " gs BT 1 0 0 1 100 100 Tm /"; + CFX_ByteString compareString3 = " 10 Tf <48656C6C6F20576F726C64> Tj ET Q\n"; EXPECT_LT(compareString1.GetLength() + compareString2.GetLength() + compareString3.GetLength(), textString.GetLength()); @@ -208,13 +209,13 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessStandardText) { EXPECT_EQ(compareString3, lastString.Right(compareString3.GetLength())); CPDF_Dictionary* externalGS = TestGetResource( &generator, "ExtGState", - lastString.Left(lastString.GetLength() - compareString3.GetLength())); + midString.Left(midString.GetLength() - compareString2.GetLength())); ASSERT_TRUE(externalGS); EXPECT_EQ(0.5f, externalGS->GetNumberFor("ca")); EXPECT_EQ(0.8f, externalGS->GetNumberFor("CA")); CPDF_Dictionary* fontDict = TestGetResource( &generator, "Font", - midString.Left(midString.GetLength() - compareString2.GetLength())); + lastString.Left(lastString.GetLength() - compareString3.GetLength())); ASSERT_TRUE(fontDict); EXPECT_EQ("Font", fontDict->GetStringFor("Type")); EXPECT_EQ("Type1", fontDict->GetStringFor("Subtype")); @@ -259,9 +260,10 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessText) { CFX_ByteString firstString = textString.Left(firstResourceAt); CFX_ByteString lastString = textString.Right(textString.GetLength() - firstResourceAt); - CFX_ByteString compareString1 = "BT 1 0 0 1 0 0 Tm /"; + // q and Q must be outside the BT .. ET operations + CFX_ByteString compareString1 = "q BT 1 0 0 1 0 0 Tm /"; CFX_ByteString compareString2 = - " 15.5 Tf q <4920616D20696E646972656374> Tj ET Q\n"; + " 15.5 Tf <4920616D20696E646972656374> Tj ET Q\n"; EXPECT_LT(compareString1.GetLength() + compareString2.GetLength(), textString.GetLength()); EXPECT_EQ(compareString1, textString.Left(compareString1.GetLength())); |