summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_edit_embeddertest.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-08-01 01:28:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-01 01:28:49 +0000
commit53d4f0a4526ef996caf5005ae84406a9467423f2 (patch)
treecf86d5f7bdd8996e5614fb00113fe6df2ddefdaf /fpdfsdk/fpdf_edit_embeddertest.cpp
parentcede561c5ae665a563409ba3bfc93c3cd6da5248 (diff)
downloadpdfium-53d4f0a4526ef996caf5005ae84406a9467423f2.tar.xz
Add FPDFText_GetFontName() API
This follows the same pattern as DefaultGetFaceName(), so the client has to call this function twice, but allocation of the string buffer happens outside pdfium. Change-Id: I06b7dcd00aca9b9b94799dad3f139617d7f5451e Reviewed-on: https://pdfium-review.googlesource.com/38870 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_edit_embeddertest.cpp')
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index c9805f50c7..3c2b05ed8a 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -1764,6 +1764,34 @@ TEST_F(FPDFEditEmbeddertest, TestGetTextRenderMode) {
UnloadPage(page);
}
+TEST_F(FPDFEditEmbeddertest, TestGetTextFontName) {
+ EXPECT_TRUE(OpenDocument("text_font.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+ ASSERT_EQ(1, FPDFPage_CountObjects(page));
+
+ // FPDFTextObj_GetFontName() positive testing.
+ FPDF_PAGEOBJECT text = FPDFPage_GetObject(page, 0);
+ unsigned long size = FPDFTextObj_GetFontName(text, nullptr, 0);
+ const char kExpectedFontName[] = "Liberation Serif";
+ ASSERT_EQ(sizeof(kExpectedFontName), size);
+ std::vector<char> font_name(size);
+ ASSERT_EQ(size, FPDFTextObj_GetFontName(text, font_name.data(), size));
+ ASSERT_STREQ(kExpectedFontName, font_name.data());
+
+ // FPDFTextObj_GetFontName() negative testing.
+ ASSERT_EQ(0U, FPDFTextObj_GetFontName(nullptr, nullptr, 0));
+
+ font_name.resize(2);
+ font_name[0] = 'x';
+ font_name[1] = '\0';
+ size = FPDFTextObj_GetFontName(text, font_name.data(), font_name.size());
+ ASSERT_EQ(sizeof(kExpectedFontName), size);
+ ASSERT_EQ(std::string("x"), std::string(font_name.data()));
+
+ UnloadPage(page);
+}
+
TEST_F(FPDFEditEmbeddertest, TestFormGetObjects) {
EXPECT_TRUE(OpenDocument("form_object.pdf"));
FPDF_PAGE page = LoadPage(0);