Correctly draw text with pattern.
CPDF_RenderStatus::DrawTextPathWithPattern() does the drawing by
creating a new path object in memory and rendering that. However, it
does not take the existing clip path into account. Add
CPDF_ClipPath::CopyClipPath() and use that in DrawTextPathWithPattern()
to copy the existing clip path into the path object that draws the text
path.
Bug: pdfium:632
Change-Id: I6d82697315b4c7537ec2c4136a0689fd5f8a48c7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/60752
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp
index c04fafa..5db9208 100644
--- a/core/fpdfapi/page/cpdf_clippath.cpp
+++ b/core/fpdfapi/page/cpdf_clippath.cpp
@@ -102,6 +102,14 @@
pTexts->clear();
}
+void CPDF_ClipPath::CopyClipPath(const CPDF_ClipPath& that) {
+ if (*this == that || !that.HasRef())
+ return;
+
+ for (size_t i = 0; i < that.GetPathCount(); ++i)
+ AppendPath(that.GetPath(i), that.GetClipType(i), /*bAutoMerge=*/false);
+}
+
void CPDF_ClipPath::Transform(const CFX_Matrix& matrix) {
PathData* pData = m_Ref.GetPrivateCopy();
for (auto& obj : pData->m_PathAndTypeList)
diff --git a/core/fpdfapi/page/cpdf_clippath.h b/core/fpdfapi/page/cpdf_clippath.h
index 6db7b3a..0e807c1 100644
--- a/core/fpdfapi/page/cpdf_clippath.h
+++ b/core/fpdfapi/page/cpdf_clippath.h
@@ -41,6 +41,7 @@
CFX_FloatRect GetClipBox() const;
void AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge);
void AppendTexts(std::vector<std::unique_ptr<CPDF_TextObject>>* pTexts);
+ void CopyClipPath(const CPDF_ClipPath& that);
void Transform(const CFX_Matrix& matrix);
private:
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 615b583..484eff1 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1958,6 +1958,7 @@
CPDF_PathObject path;
path.set_filltype(FXFILL_WINDING);
+ path.m_ClipPath.CopyClipPath(m_LastClipPath);
path.m_ClipPath.AppendTexts(&pCopy);
path.m_ColorState = textobj->m_ColorState;
path.m_GeneralState = textobj->m_GeneralState;
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 8ee6d6c..beca1be 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -328,9 +328,6 @@
# TODO(pdfium:304): Remove after associated bug is fixed
bug_304.pdf * * *
-# TODO(pdfium:632): Remove after associated bug is fixed
-bug_632.in * * *
-
# TODO(pdfium:1331): Remove after associated bug is fixed
bug_1331.in * * *