Add an embedder test to demonstrate a FPDFText_LoadFont() failure
Add a test case to show loading bug_2094.ttf does not work. The test
font file has the same problematic properties as the font in the bug
report, but it was created from scratch using FontForge.
Bug: pdfium:2094
Change-Id: I7d337ad905173ae7dbe03edbe89b1011a2a29af5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/113453
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 00cc7b2..154fc44 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -374,6 +374,22 @@
VerifySavedDocument(400, 400, checksum);
}
+TEST_F(FPDFEditEmbedderTest, Bug2094) {
+ CreateEmptyDocument();
+ ScopedFPDFPage page(FPDFPage_New(document(), 0, 400, 400));
+ std::string font_path = PathService::GetTestFilePath("fonts/bug_2094.ttf");
+ ASSERT_FALSE(font_path.empty());
+
+ std::vector<uint8_t> font_data = GetFileContents(font_path.c_str());
+ ASSERT_FALSE(font_data.empty());
+
+ ScopedFPDFFont font(FPDFText_LoadFont(document(), font_data.data(),
+ font_data.size(), FPDF_FONT_TRUETYPE,
+ /*cid=*/true));
+ // TODO(crbug.com/pdfium/2094): Make FPDFText_LoadFont() succeed.
+ EXPECT_FALSE(font);
+}
+
TEST_F(FPDFEditEmbedderTest, EmptyCreation) {
CreateEmptyDocument();
FPDF_PAGE page = FPDFPage_New(document(), 0, 640.0, 480.0);
diff --git a/testing/resources/fonts/bug_2094.ttf b/testing/resources/fonts/bug_2094.ttf
new file mode 100644
index 0000000..c15ae13
--- /dev/null
+++ b/testing/resources/fonts/bug_2094.ttf
Binary files differ