vcl/qa/cppunit/pdfexport/data/tdf155161.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx      |   40 ++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

New commits:
commit 198a1afe4d4c3c57a0cf6dc69c2494a2b9119751
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Wed Jun 14 16:39:18 2023 +0300
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Thu Jun 15 13:51:17 2023 +0200

    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: خالد حسني <kha...@libreoffice.org>

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
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf155161.odt 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();

Reply via email to