scribus/scribus-1.5.8-poppler-22.0.2.patch

130 lines
3.8 KiB
Diff

From 85c0dff3422fa3c26fbc2e8d8561f597ec24bd92 Mon Sep 17 00:00:00 2001
From: Jean Ghali <jghali@libertysurf.fr>
Date: Wed, 2 Feb 2022 23:12:52 +0000
Subject: [PATCH] #16734: Build break with poppler 22.2.0
git-svn-id: svn://scribus.net/trunk/Scribus@24884 11d20701-8431-0410-a711-e3c959e3b870
---
scribus/plugins/import/pdf/slaoutput.cpp | 47 +++++++++++++++++++-----
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/scribus/plugins/import/pdf/slaoutput.cpp b/scribus/plugins/import/pdf/slaoutput.cpp
index 5894bf2ad6..3650c96f52 100644
--- a/scribus/plugins/import/pdf/slaoutput.cpp
+++ b/scribus/plugins/import/pdf/slaoutput.cpp
@@ -7,6 +7,11 @@ for which a new license (GPL+exception) is in place.
#include "slaoutput.h"
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+#include <memory>
+#include <optional>
+#endif
+
#include <poppler/GlobalParams.h>
#include <poppler/poppler-config.h>
#include <poppler/FileSpec.h>
@@ -3027,18 +3032,24 @@ void SlaOutputDev::markPoint(POPPLER_CONST char *name, Dict *properties)
void SlaOutputDev::updateFont(GfxState *state)
{
GfxFont *gfxFont;
- GfxFontLoc *fontLoc;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+ std::optional<GfxFontLoc> fontLoc;
+ const GooString * fileName = nullptr;
+ std::unique_ptr<FoFiTrueType> ff;
+#else
+ GfxFontLoc * fontLoc = nullptr;
+ GooString * fileName = nullptr;
+ FoFiTrueType * ff = nullptr;
+#endif
GfxFontType fontType;
SlaOutFontFileID *id;
SplashFontFile *fontFile;
SplashFontSrc *fontsrc = nullptr;
- FoFiTrueType *ff;
Object refObj, strObj;
- GooString *fileName;
- char *tmpBuf;
+ char *tmpBuf = nullptr;
int tmpBufLen = 0;
- int *codeToGID;
- const double *textMat;
+ int *codeToGID = nullptr;
+ const double *textMat = nullptr;
double m11, m12, m21, m22, fontSize;
SplashCoord mat[4];
int n = 0;
@@ -3046,9 +3057,6 @@ void SlaOutputDev::updateFont(GfxState *state)
SplashCoord matrix[6];
m_font = nullptr;
- fileName = nullptr;
- tmpBuf = nullptr;
- fontLoc = nullptr;
gfxFont = state->getFont();
if (!gfxFont)
@@ -3083,7 +3091,11 @@ void SlaOutputDev::updateFont(GfxState *state)
}
else
{ // gfxFontLocExternal
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+ fileName = fontLoc->pathAsGooString();
+#else
fileName = fontLoc->path;
+#endif
fontType = fontLoc->fontType;
}
@@ -3136,9 +3148,14 @@ void SlaOutputDev::updateFont(GfxState *state)
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
if (ff)
{
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+ codeToGID = ((Gfx8BitFont*) gfxFont)->getCodeToGIDMap(ff.get());
+ ff.reset();
+#else
codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
- n = 256;
delete ff;
+#endif
+ n = 256;
}
else
{
@@ -3209,8 +3226,13 @@ void SlaOutputDev::updateFont(GfxState *state)
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
if (! ff)
goto err2;
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+ codeToGID = ((GfxCIDFont*) gfxFont)->getCodeToGIDMap(ff.get(), &n);
+ ff.reset();
+#else
codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
delete ff;
+#endif
}
if (!(fontFile = m_fontEngine->loadTrueTypeFont(
id,
@@ -3247,14 +3269,19 @@ void SlaOutputDev::updateFont(GfxState *state)
mat[3] = -m22;
m_font = m_fontEngine->getFont(fontFile, mat, matrix);
+#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(22, 2, 0)
delete fontLoc;
+#endif
if (fontsrc && !fontsrc->isFile)
fontsrc->unref();
return;
err2:
delete id;
+#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(22, 2, 0)
delete fontLoc;
+#endif
+
err1:
if (fontsrc && !fontsrc->isFile)
fontsrc->unref();