View Issue Details

IDProjectCategoryView StatusLast Update
0016734ScribusPDFpublic2022-02-02 23:13
Reporterfoutrelis Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Product Version1.5.8 
Fixed in Version1.5.9.svn 
Summary0016734: Build break with poppler 22.2.0
DescriptionI cobbled together a patch to fix this but it can likely be cleaned up a bit. (Especially the new scope created under "case fontTrueTypeOT".)

The following poppler commits are relevant here:

https://cgit.freedesktop.org/poppler/poppler/commit/?id=953c9c762f346236d856327833f3a550b993138a
https://cgit.freedesktop.org/poppler/poppler/commit/?id=9389df54ca8f9c182153aa13eb1109ea98fb307c
https://cgit.freedesktop.org/poppler/poppler/commit/?id=9451ca15dc63b908786e93f86f84862b11fc45dd
TagsNo tags attached.
PatchNo

Activities

foutrelis

2022-02-02 10:31

reporter  

poppler-22.2.0.patch (3,853 bytes)   
diff -upr scribus-1.5.8.orig/scribus/plugins/import/pdf/slaoutput.cpp scribus-1.5.8/scribus/plugins/import/pdf/slaoutput.cpp
--- scribus-1.5.8.orig/scribus/plugins/import/pdf/slaoutput.cpp	2022-01-23 18:16:01.000000000 +0200
+++ scribus-1.5.8/scribus/plugins/import/pdf/slaoutput.cpp	2022-02-02 12:21:07.441133975 +0200
@@ -7,6 +7,8 @@ for which a new license (GPL+exception)
 
 #include "slaoutput.h"
 
+#include <memory>
+#include <optional>
 #include <poppler/GlobalParams.h>
 #include <poppler/poppler-config.h>
 #include <poppler/FileSpec.h>
@@ -3027,14 +3029,19 @@ void SlaOutputDev::markPoint(POPPLER_CON
 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;
+#else
+	GfxFontLoc *fontLoc = nullptr;
+	GooString *fileName = nullptr;
+	FoFiTrueType *ff;
+#endif
 	GfxFontType fontType;
 	SlaOutFontFileID *id;
 	SplashFontFile *fontFile;
 	SplashFontSrc *fontsrc = nullptr;
-	FoFiTrueType *ff;
 	Object refObj, strObj;
-	GooString *fileName;
 	char *tmpBuf;
 	int tmpBufLen = 0;
 	int *codeToGID;
@@ -3046,9 +3053,7 @@ void SlaOutputDev::updateFont(GfxState *
 	SplashCoord matrix[6];
 
 	m_font = nullptr;
-	fileName = nullptr;
 	tmpBuf = nullptr;
-	fontLoc = nullptr;
 
 	gfxFont = state->getFont();
 	if (!gfxFont)
@@ -3083,7 +3088,11 @@ void SlaOutputDev::updateFont(GfxState *
 		}
 		else
 		{ // gfxFontLocExternal
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+			fileName = fontLoc->pathAsGooString();
+#else
 			fileName = fontLoc->path;
+#endif
 			fontType = fontLoc->fontType;
 		}
 
@@ -3130,15 +3139,23 @@ void SlaOutputDev::updateFont(GfxState *
 			break;
 		case fontTrueType:
 		case fontTrueTypeOT:
+			{
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+			std::unique_ptr<FoFiTrueType> ff;
+#endif
 			if (fileName)
 				ff = FoFiTrueType::load(fileName->getCString());
 			else
 				ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
 			if (ff)
 			{
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+				codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff.get());
+#else
 				codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
-				n = 256;
 				delete ff;
+#endif
+				n = 256;
 			}
 			else
 			{
@@ -3154,6 +3171,7 @@ void SlaOutputDev::updateFont(GfxState *
 				gfxFont->getName() ? gfxFont->getName()->getCString() : "(unnamed)");
 				goto err2;
 			}
+			}
 			break;
 		case fontCIDType0:
 		case fontCIDType0C:
@@ -3203,14 +3221,21 @@ void SlaOutputDev::updateFont(GfxState *
 			}
 			else
 			{
+#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(22, 2, 0)
+				std::unique_ptr<FoFiTrueType> ff;
+#endif
 				if (fileName)
 					ff = FoFiTrueType::load(fileName->getCString());
 				else
 					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);
+#else
 				codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
 				delete ff;
+#endif
 			}
 			if (!(fontFile = m_fontEngine->loadTrueTypeFont(
 							id,
@@ -3247,14 +3272,18 @@ void SlaOutputDev::updateFont(GfxState *
 	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();
poppler-22.2.0.patch (3,853 bytes)   

jghali

2022-02-02 23:13

administrator   ~0049504

Fixed, thanks for the patch!

Issue History

Date Modified Username Field Change
2022-02-02 10:31 foutrelis New Issue
2022-02-02 10:31 foutrelis File Added: poppler-22.2.0.patch
2022-02-02 23:13 jghali Assigned To => jghali
2022-02-02 23:13 jghali Status new => resolved
2022-02-02 23:13 jghali Resolution open => fixed
2022-02-02 23:13 jghali Fixed in Version => 1.5.9.svn
2022-02-02 23:13 jghali Note Added: 0049504