diff options
author | Nicolas Pena <npm@chromium.org> | 2017-05-02 14:12:50 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-02 18:37:40 +0000 |
commit | b31618571938e4873dcf1cdd44eeedb40caa5bd7 (patch) | |
tree | a337f11a62a35e8c0d52be8c5c9ec55902a6055a /public | |
parent | 336544a7451ac80c9f33216b7f61e9347d251108 (diff) | |
download | pdfium-b31618571938e4873dcf1cdd44eeedb40caa5bd7.tar.xz |
Add API to create a text object using a loaded font.
There is already a method to add text from standard font, this CL adds
an option to add text using a loaded font. The font set into a text object
is ref counted and may be released, so call LoadFont on this new text obj,
and add a method to close the font. This CL also improves the SetText method
so that it now uses a WideString, in preparation for CID fonts with non-Latin
characters.
Bug: pdfium:667
Change-Id: I6829d702357d2a898a12f5297e4fd2ec993a9891
Reviewed-on: https://pdfium-review.googlesource.com/4770
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'public')
-rw-r--r-- | public/cpp/fpdf_deleters.h | 5 | ||||
-rw-r--r-- | public/fpdf_edit.h | 23 |
2 files changed, 26 insertions, 2 deletions
diff --git a/public/cpp/fpdf_deleters.h b/public/cpp/fpdf_deleters.h index d56daf5c55..238ef30e62 100644 --- a/public/cpp/fpdf_deleters.h +++ b/public/cpp/fpdf_deleters.h @@ -6,6 +6,7 @@ #define PUBLIC_CPP_FPDF_DELETERS_H_ #include "public/fpdf_dataavail.h" +#include "public/fpdf_edit.h" #include "public/fpdf_formfill.h" #include "public/fpdf_structtree.h" #include "public/fpdf_text.h" @@ -43,4 +44,8 @@ struct FPDFStructTreeDeleter { inline void operator()(FPDF_STRUCTTREE tree) { FPDF_StructTree_Close(tree); } }; +struct FPDFFontDeleter { + inline void operator()(FPDF_FONT font) { FPDFFont_Close(font); } +}; + #endif // PUBLIC_CPP_FPDF_DELETERS_H_ diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index 4d06c2a0c8..5784b90feb 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -436,11 +436,11 @@ DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, // Set the text for a textobject. If it had text, it will be replaced. // // text_object - handle to the text object. -// text - string containing the text to be added. +// text - the UTF-16LE encoded string containing the text to be added. // // Returns TRUE on success DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetText(FPDF_PAGEOBJECT text_object, - FPDF_BYTESTRING text); + FPDF_WIDESTRING text); // Returns a font object loaded from a stream of data. The font is loaded // into the document. The caller does not need to free the returned object. @@ -452,6 +452,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFText_SetText(FPDF_PAGEOBJECT text_object, // type. // cid - a boolean specifying if the font is a CID font or not. // +// The loaded font can be closed using FPDF_Font_Close. +// // Returns NULL on failure DLLEXPORT FPDF_FONT STDCALL FPDFText_LoadFont(FPDF_DOCUMENT document, const uint8_t* data, @@ -459,6 +461,23 @@ DLLEXPORT FPDF_FONT STDCALL FPDFText_LoadFont(FPDF_DOCUMENT document, int font_type, FPDF_BOOL cid); +// Close a loaded PDF font. +// +// font - Handle to the loaded font. +DLLEXPORT void STDCALL FPDFFont_Close(FPDF_FONT font); + +// Create a new text object using a loaded font. +// +// document - handle to the document. +// font - handle to the font object. +// font_size - the font size for the new text object. +// +// Returns a handle to a new text object, or NULL on failure +DLLEXPORT FPDF_PAGEOBJECT STDCALL +FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, + FPDF_FONT font, + float font_size); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus |