summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp17
-rw-r--r--fpdfsdk/fpdf_edittext.cpp37
-rw-r--r--fpdfsdk/fpdf_view_c_api_test.c1
3 files changed, 55 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 9464417da1..445b0cc6b9 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -1487,6 +1487,23 @@ TEST_F(FPDFEditEmbeddertest, AddStandardFontText) {
FPDF_ClosePage(page);
}
+TEST_F(FPDFEditEmbeddertest, TestGetTextRenderMode) {
+ EXPECT_TRUE(OpenDocument("text_render_mode.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+ ASSERT_EQ(2, FPDFPage_CountObjects(page));
+
+ ASSERT_EQ(-1, FPDFText_GetTextRenderMode(nullptr));
+
+ FPDF_PAGEOBJECT fill = FPDFPage_GetObject(page, 0);
+ ASSERT_EQ(FPDF_TEXTRENDERMODE_FILL, FPDFText_GetTextRenderMode(fill));
+
+ FPDF_PAGEOBJECT stroke = FPDFPage_GetObject(page, 1);
+ ASSERT_EQ(FPDF_TEXTRENDERMODE_STROKE, FPDFText_GetTextRenderMode(stroke));
+
+ UnloadPage(page);
+}
+
// Tests adding text from standard font using FPDFText_LoadStandardFont.
TEST_F(FPDFEditEmbeddertest, AddStandardFontText2) {
// Start with a blank page
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 3115e2a16e..c552d615e4 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -14,6 +14,7 @@
#include "core/fpdfapi/font/cpdf_type1font.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_textobject.h"
+#include "core/fpdfapi/page/cpdf_textstate.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
@@ -27,6 +28,31 @@
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "public/fpdf_edit.h"
+// These checks are here because core/ and public/ cannot depend on each other.
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL) ==
+ FPDF_TEXTRENDERMODE_FILL,
+ "TextRenderingMode::MODE_FILL value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_STROKE) ==
+ FPDF_TEXTRENDERMODE_STROKE,
+ "TextRenderingMode::MODE_STROKE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_STROKE) ==
+ FPDF_TEXTRENDERMODE_FILL_STROKE,
+ "TextRenderingMode::MODE_FILL_STROKE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_INVISIBLE) ==
+ FPDF_TEXTRENDERMODE_INVISIBLE,
+ "TextRenderingMode::MODE_INVISIBLE value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_CLIP) ==
+ FPDF_TEXTRENDERMODE_FILL_CLIP,
+ "TextRenderingMode::MODE_FILL_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_STROKE_CLIP) ==
+ FPDF_TEXTRENDERMODE_STROKE_CLIP,
+ "TextRenderingMode::MODE_STROKE_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_FILL_STROKE_CLIP) ==
+ FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP,
+ "TextRenderingMode::MODE_FILL_STROKE_CLIP value mismatch");
+static_assert(static_cast<int>(TextRenderingMode::MODE_CLIP) ==
+ FPDF_TEXTRENDERMODE_CLIP,
+ "TextRenderingMode::MODE_CLIP value mismatch");
namespace {
CPDF_Dictionary* LoadFontDesc(CPDF_Document* pDoc,
@@ -545,3 +571,14 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
pTextObj->DefaultStates();
return FPDFPageObjectFromCPDFPageObject(pTextObj.release());
}
+
+FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text) {
+ if (!text)
+ return -1;
+
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return -1;
+
+ return static_cast<int>(pTextObj->m_TextState.GetTextMode());
+}
diff --git a/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c
index 997423a4a8..1837b58e2a 100644
--- a/fpdfsdk/fpdf_view_c_api_test.c
+++ b/fpdfsdk/fpdf_view_c_api_test.c
@@ -197,6 +197,7 @@ int CheckPDFiumCApi() {
CHK(FPDFPath_SetStrokeWidth);
CHK(FPDFTextObj_GetFontSize);
CHK(FPDFText_GetMatrix);
+ CHK(FPDFText_GetTextRenderMode);
CHK(FPDFText_LoadFont);
CHK(FPDFText_LoadStandardFont);
CHK(FPDFText_SetFillColor);