vcl/source/gdi/pdfwriter_impl.cxx | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-)
New commits: commit 6eab55912fc0e6bcb4b2ca15fd626d54b9346d43 Author: Khaled Hosny <kha...@libreoffice.org> AuthorDate: Thu Jun 15 06:27:38 2023 +0300 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jun 15 20:53:56 2023 +0200 Don’t add empty Fonts dictionary to Type 3 font resources If the Type 3 font does not use any other fonts, skip writing Fonts to its Resources dictionary. Change-Id: I1d0489debeb9f0e24022316551eb234b279381c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153100 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@libreoffice.org> (cherry picked from commit 845fbfcce9091e541bab657163b026aad8648261) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153085 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 718433aafc02..7ad67f9f1772 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2755,22 +2755,26 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace, } // write font dict - auto nFontDict = createObject(); - aLine.setLength(0); - aLine.append(OString::number(nFontDict) + " 0 obj\n<<"); - for (auto nFontID : aUsedFonts) + auto nFontDict = -1; + if (!aUsedFonts.empty()) { - aLine.append("/F" - + OString::number(nFontID) - + " " - + OString::number(rFontIDToObject[nFontID]) - + " 0 R"); + nFontDict = createObject(); + aLine.setLength(0); + aLine.append(OString::number(nFontDict) + " 0 obj\n<<"); + for (auto nFontID : aUsedFonts) + { + aLine.append("/F" + + OString::number(nFontID) + + " " + + OString::number(rFontIDToObject[nFontID]) + + " 0 R"); + } + aLine.append(">>\nendobj\n\n"); + if (!updateObject(nFontDict)) + return false; + if (!writeBuffer(aLine)) + return false; } - aLine.append(">>\nendobj\n\n"); - if (!updateObject(nFontDict)) - return false; - if (!writeBuffer(aLine)) - return false; // write ExtGState objects if (!aUsedAlpha.empty()) @@ -2806,7 +2810,8 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace, // write resources dict aLine.setLength(0); aLine.append(OString::number(nResources) + " 0 obj\n"); - aResourceDict.append(aLine, nFontDict); + if (!aUsedFonts.empty()) + aResourceDict.append(aLine, nFontDict); aLine.append("endobj\n\n"); if (!updateObject(nResources)) return false;