summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit/pdfexport
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-06-14 16:39:18 +0300
committerخالد حسني <khaled@libreoffice.org>2023-06-15 13:51:17 +0200
commit198a1afe4d4c3c57a0cf6dc69c2494a2b9119751 (patch)
tree883304082698a9df07275a1aa265a96cc3b233a8 /vcl/qa/cppunit/pdfexport
parent845fbfcce9091e541bab657163b026aad8648261 (diff)
tdf#155161: Add test
The test document embeds Cantarell font because we don’t bundle any fonts with CFF2 table (or CFF table for that matter). Change-Id: Icdbab58ea3999baa75bc85fad60172218d9f6058 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153054 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'vcl/qa/cppunit/pdfexport')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf155161.odtbin0 -> 123319 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx40
2 files changed, 40 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf155161.odt b/vcl/qa/cppunit/pdfexport/data/tdf155161.odt
new file mode 100644
index 000000000000..1d22bb7c4d01
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf155161.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 0739cd25cd8a..e19f989ce9b9 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4779,6 +4779,46 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf152246)
}
}
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf155161)
+{
+// TODO: We seem to get a fallback font on Windows
+#ifndef _WIN32
+ vcl::filter::PDFDocument aDocument;
+ load(u"tdf155161.odt", aDocument);
+
+ // Check that all fonts in the document are Type 3 fonts
+ int nFonts = 0;
+ for (const auto& aElement : aDocument.GetElements())
+ {
+ auto pObject = dynamic_cast<vcl::filter::PDFObjectElement*>(aElement.get());
+ if (!pObject)
+ continue;
+ auto pType = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("Type"));
+ if (pType && pType->GetValue() == "Font")
+ {
+ auto pSubtype = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("Subtype"));
+ CPPUNIT_ASSERT(pSubtype);
+ CPPUNIT_ASSERT_EQUAL(OString("Type3"), pSubtype->GetValue());
+
+ auto pName = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("Name"));
+ CPPUNIT_ASSERT(pName);
+ CPPUNIT_ASSERT_EQUAL(OString("Cantarell-Regular"), pName->GetValue());
+
+ nFonts++;
+ }
+ }
+
+#ifdef MACOSX
+ // There must be two fonts
+ CPPUNIT_ASSERT_EQUAL(2, nFonts);
+#else
+ // But it seems that embedded variable fonts don’t register all supported
+ // styles on Linux, so the bold and regular text use the same regular font.
+ CPPUNIT_ASSERT(nFonts);
+#endif
+#endif
+}
+
} // end anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();