summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_edittext.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-06-19 15:45:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-19 15:45:42 +0000
commitc765d2ac867611935cff6b5c5a2ff8575fe85162 (patch)
tree607fbc0d819dfb4101b7b03210f0545d9b1eb754 /fpdfsdk/fpdf_edittext.cpp
parenta700b851c31a67ce4034731e8c06808498a9903b (diff)
downloadpdfium-c765d2ac867611935cff6b5c5a2ff8575fe85162.tar.xz
Add FPDFText_GetMatrix() API
This is similar to FPDFPath_GetMatrix(), but works on text, not path objects. Change-Id: If268362b7fa4398124b953e0e2225074523f5f65 Reviewed-on: https://pdfium-review.googlesource.com/35434 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_edittext.cpp')
-rw-r--r--fpdfsdk/fpdf_edittext.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 8186d8d894..a927e16e14 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -394,6 +394,11 @@ CPDF_Font* LoadCompositeFont(CPDF_Document* pDoc,
return pDoc->LoadFont(fontDict);
}
+CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
+ auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
+ return obj ? obj->AsText() : nullptr;
+}
+
} // namespace
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
@@ -481,6 +486,31 @@ FPDFText_SetFillColor(FPDF_PAGEOBJECT text_object,
return FPDFPageObj_SetFillColor(text_object, R, G, B, A);
}
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_PAGEOBJECT text,
+ double* a,
+ double* b,
+ double* c,
+ double* d,
+ double* e,
+ double* f) {
+ if (!text || !a || !b || !c || !d || !e || !f)
+ return false;
+
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return false;
+
+ CFX_Matrix text_matrix = pTextObj->GetTextMatrix();
+ *a = text_matrix.a;
+ *b = text_matrix.b;
+ *c = text_matrix.c;
+ *d = text_matrix.d;
+ *e = text_matrix.e;
+ *f = text_matrix.f;
+
+ return true;
+}
+
FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font) {
CPDF_Font* pFont = CPDFFontFromFPDFFont(font);
if (!pFont)