Bug#1012818: inkscape: Please update for Poppler 22.06
Package: inkscape
Severity: normal
Tags: patch
X-Debbugs-Cc: nathan.teodosio@canonical.com
Dear Maintainer,
Since Poppler 22.06 is making its way into experimental (currently in NEW[1]),
Inkscape will need the corresponding compatibility changes from upstream to
build. I cherry-picked them in the attached patch and with Sbuilder made sure
it builds against the new Poppler.
[1]: https://ftp-master.debian.org/new.html
-- System Information:
Debian Release: bookworm/sid
APT prefers kinetic
APT policy: (500, 'kinetic')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.15.0-33-generic (SMP w/8 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages inkscape depends on:
ii lib2geom1.1.0 1.1-3
ii libatkmm-1.6-1v5 2.28.2-1build1
ii libboost-filesystem1.74.0 1.74.0-14ubuntu4
ii libc6 2.35-0ubuntu3
ii libcairo2 1.16.0-5ubuntu2
ii libcairomm-1.0-1v5 1.12.2-4build3
ii libcdr-0.1-1 0.1.6-2build3
ii libdbus-glib-1-2 0.112-2build1
ii libfontconfig1 2.13.1-4.4ubuntu1
ii libfreetype6 2.12.1+dfsg-2
ii libgc1 1:8.0.6-1.1build1
ii libgcc-s1 12.1.0-2ubuntu1
ii libgdk-pixbuf-2.0-0 2.42.8+dfsg-1
ii libglib2.0-0 2.72.1-1
ii libglibmm-2.4-1v5 2.66.2-2
ii libgomp1 12.1.0-2ubuntu1
ii libgsl27 2.7.1+dfsg-3
ii libgspell-1-2 1.10.0-1
ii libgtk-3-0 3.24.33-2ubuntu1
ii libgtkmm-3.0-1v5 3.24.5-1build1
ii libharfbuzz0b 2.7.4-1ubuntu4
ii libjpeg8 8c-2ubuntu10
ii liblcms2-2 2.12~rc1-2build2
ii libmagick++-6.q16-8 8:6.9.11.60+dfsg-1.3build2
ii libpango-1.0-0 1.50.7+ds-1
ii libpangocairo-1.0-0 1.50.7+ds-1
ii libpangoft2-1.0-0 1.50.7+ds-1
ii libpangomm-1.4-1v5 2.46.2-1
ii libpng16-16 1.6.37-5
ii libpoppler-glib8 22.06.0-1
pn libpoppler118 <none>
ii libpotrace0 1.16-2
ii libreadline8 8.1.2-1.2
ii librevenge-0.0-0 0.0.4-6ubuntu7
ii librsvg2-common 2.52.5+dfsg-3
ii libsigc++-2.0-0v5 2.10.4-2ubuntu3
ii libsoup2.4-1 2.74.2-3
ii libstdc++6 12.1.0-2ubuntu1
ii libvisio-0.1-1 0.1.7-1build6
ii libwpg-0.3-3 0.3.3-1build3
ii libx11-6 2:1.7.5-1
ii libxml2 2.9.14+dfsg-1
ii libxslt1.1 1.1.34-4build2
ii python3 3.10.4-0ubuntu2
ii zlib1g 1:1.2.11.dfsg-2ubuntu9
Versions of packages inkscape recommends:
ii aspell 0.60.8-4build1
pn fig2dev <none>
ii imagemagick 8:6.9.11.60+dfsg-1.3build2
ii imagemagick-6.q16 [imagemagick] 8:6.9.11.60+dfsg-1.3build2
pn libimage-magick-perl <none>
pn libwmf-bin <none>
ii python3-lxml 4.8.0-1build1
ii python3-numpy 1:1.21.5-1build2
ii python3-scour 0.38.2-2
Versions of packages inkscape suggests:
pn dia <none>
pn inkscape-tutorials <none>
pn libsvg-perl <none>
ii pstoedit 3.78-1
pn python3-uniconvertor <none>
ii ruby 1:3.0~exp1
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index feecefa0434d82f131a203311f08b4ee7165492a..d6e2ede4f358e8761436bf68bdf93be306f03cb9 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -30,6 +30,7 @@
#include "Gfx.h"
#include "pdf-parser.h"
#include "util/units.h"
+#include "poppler-transition-api.h"
#include "glib/poppler-features.h"
#include "goo/gmem.h"
@@ -2158,7 +2159,7 @@ void PdfParser::opSetCharSpacing(Object args[], int /*numArgs*/)
// TODO not good that numArgs is ignored but args[] is used:
void PdfParser::opSetFont(Object args[], int /*numArgs*/)
{
- GfxFont *font = res->lookupFont(args[0].getName());
+ auto font = res->lookupFont(args[0].getName());
if (!font) {
// unsetting the font (drawing no text) is better than using the
@@ -2179,7 +2180,9 @@ void PdfParser::opSetFont(Object args[], int /*numArgs*/)
fflush(stdout);
}
+#if !POPPLER_CHECK_VERSION(22, 4, 0)
font->incRefCnt();
+#endif
state->setFont(font, args[1].getNum());
fontChanged = gTrue;
}
@@ -2373,7 +2376,6 @@ void PdfParser::doShowText(const GooString *s) {
#else
void PdfParser::doShowText(GooString *s) {
#endif
- GfxFont *font;
int wMode;
double riseX, riseY;
CharCode code;
@@ -2392,7 +2394,7 @@ void PdfParser::doShowText(GooString *s) {
#endif
int len, n, uLen;
- font = state->getFont();
+ auto font = state->getFont();
wMode = font->getWMode();
builder->beginString(state);
@@ -2445,10 +2447,10 @@ void PdfParser::doShowText(GooString *s) {
//out->updateCTM(state, 1, 0, 0, 1, 0, 0);
if (false){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy,
code, u, uLen)) {*/
- _POPPLER_CALL_ARGS(charProc, ((Gfx8BitFont *)font)->getCharProc, code);
- if ((resDict = ((Gfx8BitFont *)font)->getResources())) {
+ _POPPLER_CALL_ARGS(charProc, _POPPLER_FONTPTR_TO_GFX8(font)->getCharProc, code);
+ if (resDict = _POPPLER_FONTPTR_TO_GFX8(font)->getResources()) {
pushResources(resDict);
- }
+ }
if (charProc.isStream()) {
//parse(&charProc, gFalse); // TODO: parse into SVG font
} else {
diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
index 50b617c25c4f669eb080f8efeaed46a8af39e447..dc9e47e45bbcada1e9b9058b875f55a383a57a5b 100644
--- a/src/extension/internal/pdfinput/poppler-transition-api.h
+++ b/src/extension/internal/pdfinput/poppler-transition-api.h
@@ -14,6 +14,12 @@
#include <glib/poppler-features.h>
+#if POPPLER_CHECK_VERSION(22, 4, 0)
+#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr.get())
+#else
+#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr)
+#endif
+
#if POPPLER_CHECK_VERSION(22, 3, 0)
#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(std::make_unique<GooString>(uri))
#else
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index eede6688933d7c23b15cb71c438b3b902e915e34..901cc8cddb8d5bf7d6ff46ca603b27e97f2e344c 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -108,7 +108,6 @@ SvgBuilder::~SvgBuilder() = default;
void SvgBuilder::_init() {
_font_style = nullptr;
- _current_font = nullptr;
_font_specification = nullptr;
_font_scaling = 1;
_need_font_update = true;
@@ -1064,11 +1063,8 @@ void SvgBuilder::updateFont(GfxState *state) {
_need_font_update = false;
updateTextMatrix(state); // Ensure that we have a text matrix built
- if (_font_style) {
- //sp_repr_css_attr_unref(_font_style);
- }
_font_style = sp_repr_css_attr_new();
- GfxFont *font = state->getFont();
+ auto font = state->getFont();
// Store original name
if (font->getName()) {
_font_specification = font->getName()->getCString();
@@ -1213,7 +1209,6 @@ void SvgBuilder::updateFont(GfxState *state) {
sp_repr_css_set_property(_font_style, "writing-mode", "tb");
}
- _current_font = font;
_invalidated_style = true;
}
diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
index fb4e64fa19a1946bfb37cdfb60b7eb9662ba5ea8..e91febd71761f9da47f9ed7ece81841a76db40e9 100644
--- a/src/extension/internal/pdfinput/svg-builder.h
+++ b/src/extension/internal/pdfinput/svg-builder.h
@@ -204,7 +204,6 @@ private:
std::vector<SvgGraphicsState> _state_stack;
SPCSSAttr *_font_style; // Current font style
- GfxFont *_current_font;
const char *_font_specification;
double _font_scaling;
bool _need_font_update;
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 3dabc94ba20d1489b6f16d2d78e96900329b8c0c..079b0dc71378126580b7c5367491e91a2b512aff 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -688,8 +688,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
// poppler does not use glib g_open. So on win32 we must use unicode call. code was copied from
// glib gstdio.c
- GooString *filename_goo = new GooString(uri);
- pdf_doc = std::make_shared<PDFDoc>(filename_goo, nullptr, nullptr, nullptr); // TODO: Could ask for password
+ pdf_doc = _POPPLER_MAKE_SHARED_PDFDOC(uri); // TODO: Could ask for password
if (!pdf_doc->isOk()) {
int error = pdf_doc->getErrorCode();
diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
index 87a19d4c420ff6c90d256aace4eded2577d18bea..50b617c25c4f669eb080f8efeaed46a8af39e447 100644
--- a/src/extension/internal/pdfinput/poppler-transition-api.h
+++ b/src/extension/internal/pdfinput/poppler-transition-api.h
@@ -14,6 +14,12 @@
#include <glib/poppler-features.h>
+#if POPPLER_CHECK_VERSION(22, 3, 0)
+#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(std::make_unique<GooString>(uri))
+#else
+#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(new GooString(uri), nullptr, nullptr, nullptr)
+#endif
+
#if POPPLER_CHECK_VERSION(0, 83, 0)
#define _POPPLER_CONST_83 const
#else
Reply to: