diff options
-rw-r--r-- | fpdfsdk/fpdf_edit_embeddertest.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/fpdf_edittext.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/fpdf_view_c_api_test.c | 1 | ||||
-rw-r--r-- | public/fpdf_edit.h | 9 |
4 files changed, 24 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp index f2690499d1..9464417da1 100644 --- a/fpdfsdk/fpdf_edit_embeddertest.cpp +++ b/fpdfsdk/fpdf_edit_embeddertest.cpp @@ -1479,6 +1479,9 @@ TEST_F(FPDFEditEmbeddertest, AddStandardFontText) { EXPECT_EQ(200., matrix_e); EXPECT_EQ(200., matrix_f); + EXPECT_EQ(0, FPDFTextObj_GetFontSize(nullptr)); + EXPECT_EQ(20, FPDFTextObj_GetFontSize(text_object3)); + // TODO(npm): Why are there issues with text rotated by 90 degrees? // TODO(npm): FPDF_SaveAsCopy not giving the desired result after this. FPDF_ClosePage(page); diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp index a927e16e14..e339c24129 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/fpdfsdk/fpdf_view_c_api_test.c b/fpdfsdk/fpdf_view_c_api_test.c index 90eca333d5..997423a4a8 100644 --- a/fpdfsdk/fpdf_view_c_api_test.c +++ b/fpdfsdk/fpdf_view_c_api_test.c @@ -195,6 +195,7 @@ int CheckPDFiumCApi() { CHK(FPDFPath_SetMatrix); CHK(FPDFPath_SetStrokeColor); CHK(FPDFPath_SetStrokeWidth); + CHK(FPDFTextObj_GetFontSize); CHK(FPDFText_GetMatrix); CHK(FPDFText_LoadFont); CHK(FPDFText_LoadStandardFont); diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index 6df5e32370..6e613bca07 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. |