Kaydet (Commit) f26ca928 authored tarafından Miklos Vajna's avatar Miklos Vajna

pdfium: replace FPDFTextObj_GetFontSize() patch with backport

Change-Id: I2a4bdcf506720f266344378cdcc71975de4293e0
Reviewed-on: https://gerrit.libreoffice.org/58146
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 1108f9c9
From b9d88e52f8c1a4a27daab5739e6c777f2dbb655a Mon Sep 17 00:00:00 2001
Date: Tue, 26 Jun 2018 15:12:48 +0000
Subject: [PATCH] Add FPDFTextObj_GetFontSize() API
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In contrast with FPDFText_GetFontSize(), this exposes the font size of
the text object according to the text state, rather than the font size
of a particular character.
Change-Id: Iac88d1aea8fb6bb5522bdaf01363aa6d32025b8f
Reviewed-on: https://pdfium-review.googlesource.com/35931
Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
---
fpdfsdk/fpdf_edit_embeddertest.cpp | 3 +++
fpdfsdk/fpdf_edittext.cpp | 11 +++++++++++
fpdfsdk/fpdf_view_c_api_test.c | 1 +
public/fpdf_edit.h | 9 +++++++++
4 files changed, 24 insertions(+)
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index a927e16e1..e339c2412 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -511,6 +511,17 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_PAGEOBJECT text,
return true;
}
+FPDF_EXPORT double FPDF_CALLCONV FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text) {
+ if (!text)
+ return 0;
+
+ CPDF_TextObject* pTextObj = CPDFTextObjectFromFPDFPageObject(text);
+ if (!pTextObj)
+ return 0;
+
+ return pTextObj->GetFontSize();
+}
+
FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font) {
CPDF_Font* pFont = CPDFFontFromFPDFFont(font);
if (!pFont)
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
index 6df5e3237..6e613bca0 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -1090,6 +1090,15 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetMatrix(FPDF_PAGEOBJECT text,
double* e,
double* f);
+// Experimental API.
+// Get the font size of a text object.
+//
+// text - handle to a text.
+//
+// Returns the font size of the text object, measured in points (about 1/72
+// inch) on success; 0 on failure.
+FPDF_EXPORT double FPDF_CALLCONV FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text);
+
// Close a loaded PDF font.
//
// font - Handle to the loaded font.
--
2.16.4
......@@ -20,7 +20,7 @@ index 912df63..3244943 100644
#include "core/fpdfapi/page/cpdf_form.h"
#include "core/fpdfapi/page/cpdf_formobject.h"
#include "core/fpdfapi/page/cpdf_imageobject.h"
@@ -440,6 +441,26 @@ FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
@@ -440,6 +441,16 @@ FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
pPageObj->Transform(matrix);
}
......@@ -33,16 +33,6 @@ index 912df63..3244943 100644
+ CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
+ return pTxtObj->CountChars();
+}
+
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object)
+{
+ if (!text_object)
+ return 0;
+
+ CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
+ return pTxtObj->GetFontSize();
+}
+
FPDF_EXPORT void FPDF_CALLCONV
FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object,
......@@ -50,7 +40,7 @@ index 912df63..3244943 100644
diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1107,6 +1107,26 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
@@ -1116,6 +1116,15 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
FPDF_FONT font,
float font_size);
......@@ -62,17 +52,6 @@ diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
+// A character count in the text object.
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
+
+
+// Get the font size of a text object.
+//
+// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
+// or FPDFPageObj_NewTextObjEx.
+//
+// Return Value:
+// The value of the font size
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
+
#ifdef __cplusplus
} // extern "C"
......
......@@ -38,15 +38,6 @@ index 3244943..f8e2418 100644
return pTxtObj->CountChars();
}
@@ -453,7 +453,7 @@ FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object)
if (!text_object)
return 0;
- CPDF_TextObject* pTxtObj = static_cast<CPDF_TextObject*>(text_object);
+ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
return pTxtObj->GetFontSize();
}
@@ -645,3 +645,23 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
pPageObj->SetDirty(true);
return true;
......@@ -75,9 +66,9 @@ diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
index 602849f..fa9902e 100644
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1016,6 +1016,22 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
@@ -1125,6 +1125,22 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
FPDF_EXPORT int FPDF_CALLCONV
FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
+// Get the stroke RGBA of a text. Range of values: 0 - 255.
+//
......
......@@ -123,9 +123,9 @@ diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
index f249e64..e14b2a5 100644
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1088,6 +1088,19 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
@@ -1125,6 +1125,19 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
FPDF_EXPORT int FPDF_CALLCONV
FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
+// Get the processed text of a text object.
+//
......
......@@ -20,8 +20,8 @@ index a52e1a9..9daffc0 100644
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_number.h"
@@ -458,6 +459,29 @@ FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object)
return pTxtObj->GetFontSize();
@@ -452,6 +453,29 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object)
return pTxtObj->CountChars();
}
+FPDF_EXPORT int FPDF_CALLCONV
......
......@@ -13,6 +13,8 @@ pdfium_patches += ubsan.patch
# Fixes build on our baseline.
pdfium_patches += build.patch.1
# Adds missing editing API
# Backport of <https://pdfium-review.googlesource.com/35931>.
pdfium_patches += 0001-Add-FPDFTextObj_GetFontSize-API.patch.patch.1
pdfium_patches += 0002-svx-more-accurate-PDF-text-importing.patch.2
pdfium_patches += 0003-svx-import-PDF-images-as-BGRA.patch.2
pdfium_patches += 0004-svx-support-PDF-text-color.patch.2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment