tdf#156084: Fix PDF export of bitmap color fonts
A regression from the commit below caused the resources dictionary of
the Type 3 font to be omitted making the images inaccessible:
commit 845fbfcce9091e541bab657163b026aad8648261
Author: Khaled Hosny <khaled@libreoffice.org>
Date: Thu Jun 15 06:27:38 2023 +0300
Don’t add empty Fonts dictionary to Type 3 font resources
Change-Id: I479ca328bd1b1228ba722678d3d9686c8456b350
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153780
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 4ccbdc2..2f83c5c 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2756,7 +2756,7 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace,
}
// write font dict
sal_Int32 nFontDict = -1;
sal_Int32 nFontDict = 0;
if (!aUsedFonts.empty())
{
nFontDict = createObject();
@@ -2811,8 +2811,7 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace,
// write resources dict
aLine.setLength(0);
aLine.append(OString::number(nResources) + " 0 obj\n");
if (!aUsedFonts.empty())
aResourceDict.append(aLine, nFontDict);
aResourceDict.append(aLine, nFontDict);
aLine.append("endobj\n\n");
if (!updateObject(nResources))
return false;
diff --git a/vcl/source/pdf/ResourceDict.cxx b/vcl/source/pdf/ResourceDict.cxx
index 3490da3..f4647cb 100644
--- a/vcl/source/pdf/ResourceDict.cxx
+++ b/vcl/source/pdf/ResourceDict.cxx
@@ -42,9 +42,9 @@ void appendResourceMap(OStringBuffer& rBuf, const char* pPrefix,
void ResourceDict::append(OStringBuffer& rBuf, sal_Int32 nFontDictObject)
{
rBuf.append("<</Font ");
rBuf.append(nFontDictObject);
rBuf.append(" 0 R\n");
rBuf.append("<<\n");
if (nFontDictObject)
rBuf.append("/Font " + OString::number(nFontDictObject) + " 0 R\n");
appendResourceMap(rBuf, "XObject", m_aXObjects);
appendResourceMap(rBuf, "ExtGState", m_aExtGStates);
appendResourceMap(rBuf, "Shading", m_aShadings);