summaryrefslogtreecommitdiff
path: root/external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-08-01 08:34:42 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-08-01 09:34:02 +0200
commitd8b7ac327cfe39f46aaa871cfa7a8fdc8b2b6b54 (patch)
tree2bf47230c7899b254773dfff62dc4b6ce1541bc0 /external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1
parent8d5a74868383e5405a2225d6a7268dec5ca9cbff (diff)
pdfium: replace FPDFTextObj_GetColor() patch with backport
Upstream already got FPDFPageObj_GetFillColor() and FPDFPageObj_GetStrokeColor(), so what was necessary is just a FPDFText_GetTextRenderMode() to find out which one to use. Change-Id: I2f31fcadee8a4377b890e01ea62ed96bce275f2b Reviewed-on: https://gerrit.libreoffice.org/58381 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1')
-rw-r--r--external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1118
1 files changed, 118 insertions, 0 deletions
diff --git a/external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1 b/external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1
new file mode 100644
index 000000000000..47874119baeb
--- /dev/null
+++ b/external/pdfium/0001-Add-FPDFText_GetTextRenderMode-API.patch.1
@@ -0,0 +1,118 @@
+From 1448cc11b9be67d2d1fcd3f2f833cc6f79ad8d42 Mon Sep 17 00:00:00 2001
+Date: Tue, 3 Jul 2018 13:52:33 +0000
+Subject: [PATCH] Add FPDFText_GetTextRenderMode() API
+
+This allows deciding if FPDFPageObj_GetFillColor() or
+FPDFPageObj_GetStrokeColor() should be used to get the effective color
+of a text object.
+
+Change-Id: Ic6e99a9eb8512b164756da8b5fcd8cd7771271ae
+Reviewed-on: https://pdfium-review.googlesource.com/36750
+Reviewed-by: dsinclair <dsinclair@chromium.org>
+Commit-Queue: dsinclair <dsinclair@chromium.org>
+---
+ fpdfsdk/fpdf_edit_embeddertest.cpp | 17 ++++++++
+ fpdfsdk/fpdf_edittext.cpp | 37 +++++++++++++++++
+ fpdfsdk/fpdf_view_c_api_test.c | 1 +
+ public/fpdf_edit.h | 17 ++++++++
+ testing/resources/text_render_mode.pdf | 75 ++++++++++++++++++++++++++++++++++
+ 5 files changed, 147 insertions(+)
+ create mode 100644 testing/resources/text_render_mode.pdf
+
+diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
+index 3115e2a16..c552d615e 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/public/fpdf_edit.h b/public/fpdf_edit.h
+index 6e613bca0..6490c18c6 100644
+--- a/public/fpdf_edit.h
++++ b/public/fpdf_edit.h
+@@ -70,6 +70,15 @@
+ #define FPDF_PRINTMODE_POSTSCRIPT2_PASSTHROUGH 4
+ #define FPDF_PRINTMODE_POSTSCRIPT3_PASSTHROUGH 5
+
++#define FPDF_TEXTRENDERMODE_FILL 0
++#define FPDF_TEXTRENDERMODE_STROKE 1
++#define FPDF_TEXTRENDERMODE_FILL_STROKE 2
++#define FPDF_TEXTRENDERMODE_INVISIBLE 3
++#define FPDF_TEXTRENDERMODE_FILL_CLIP 4
++#define FPDF_TEXTRENDERMODE_STROKE_CLIP 5
++#define FPDF_TEXTRENDERMODE_FILL_STROKE_CLIP 6
++#define FPDF_TEXTRENDERMODE_CLIP 7
++
+ typedef struct FPDF_IMAGEOBJ_METADATA {
+ // The image width in pixels.
+ unsigned int width;
+@@ -1116,6 +1125,14 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
+ FPDF_FONT font,
+ float font_size);
+
++// Experimental API.
++// Get the text rendering mode of a text object.
++//
++// text - the handle to the text object.
++//
++// Returns one of the FPDF_TEXTRENDERMODE_* flags on success, -1 on error.
++FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text);
++
+ #ifdef __cplusplus
+ } // extern "C"
+ #endif // __cplusplus
+--
+2.16.4
+