]>
Commit | Line | Data |
---|---|---|
42a2ddce JB |
1 | From a18c57ffff313fd08bc8a44f6b6bf0b01d7e9b75 Mon Sep 17 00:00:00 2001 |
2 | From: Evangelos Foutras <evangelos@foutrelis.com> | |
3 | Date: Sun, 20 Mar 2022 22:41:51 -0300 | |
4 | Subject: [PATCH] Ensure compatibility with Poppler 22.03 and later | |
5 | ||
6 | This change ensures that Inkscape will build against Poppler 22.03 after | |
7 | the changes that were made to the constructor of `PDFDoc`. | |
8 | ||
9 | See: https://gitlab.freedesktop.org/poppler/poppler/-/commit/4f2abd3ef | |
10 | ||
11 | Co-authored-by: Rafael Siejakowski <rs@rs-math.net> | |
12 | --- | |
13 | src/extension/internal/pdfinput/pdf-input.cpp | 3 +-- | |
14 | src/extension/internal/pdfinput/poppler-transition-api.h | 6 ++++++ | |
15 | 2 files changed, 7 insertions(+), 2 deletions(-) | |
16 | ||
17 | diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp | |
18 | index 3dabc94ba2..079b0dc713 100644 | |
19 | --- a/src/extension/internal/pdfinput/pdf-input.cpp | |
20 | +++ b/src/extension/internal/pdfinput/pdf-input.cpp | |
21 | @@ -688,8 +688,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { | |
22 | ||
23 | // poppler does not use glib g_open. So on win32 we must use unicode call. code was copied from | |
24 | // glib gstdio.c | |
25 | - GooString *filename_goo = new GooString(uri); | |
26 | - pdf_doc = std::make_shared<PDFDoc>(filename_goo, nullptr, nullptr, nullptr); // TODO: Could ask for password | |
27 | + pdf_doc = _POPPLER_MAKE_SHARED_PDFDOC(uri); // TODO: Could ask for password | |
28 | ||
29 | if (!pdf_doc->isOk()) { | |
30 | int error = pdf_doc->getErrorCode(); | |
31 | diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h | |
32 | index 87a19d4c42..50b617c25c 100644 | |
33 | --- a/src/extension/internal/pdfinput/poppler-transition-api.h | |
34 | +++ b/src/extension/internal/pdfinput/poppler-transition-api.h | |
35 | @@ -14,6 +14,12 @@ | |
36 | ||
37 | #include <glib/poppler-features.h> | |
38 | ||
39 | +#if POPPLER_CHECK_VERSION(22, 3, 0) | |
40 | +#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(std::make_unique<GooString>(uri)) | |
41 | +#else | |
42 | +#define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(new GooString(uri), nullptr, nullptr, nullptr) | |
43 | +#endif | |
44 | + | |
45 | #if POPPLER_CHECK_VERSION(0, 83, 0) | |
46 | #define _POPPLER_CONST_83 const | |
47 | #else | |
48 | -- | |
49 | GitLab | |
50 | ||
51 | From d989cdf1059c78bc3bb6414330242073768d640b Mon Sep 17 00:00:00 2001 | |
52 | From: Rafael Siejakowski <rs@rs-math.net> | |
53 | Date: Mon, 4 Apr 2022 22:09:39 -0300 | |
54 | Subject: [PATCH] Compatibility with Poppler 22.04 | |
55 | ||
56 | Replace vanilla pointers with std::shared_ptr for pointers to fonts; | |
57 | eliminate manual ref-counting. | |
58 | ||
59 | Fixes https://gitlab.com/inkscape/inkscape/-/issues/3387 | |
60 | --- | |
61 | src/extension/internal/pdfinput/pdf-parser.cpp | 14 ++++++++------ | |
62 | .../internal/pdfinput/poppler-transition-api.h | 6 ++++++ | |
63 | src/extension/internal/pdfinput/svg-builder.cpp | 7 +------ | |
64 | src/extension/internal/pdfinput/svg-builder.h | 1 - | |
65 | 4 files changed, 15 insertions(+), 13 deletions(-) | |
66 | ||
67 | diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp | |
68 | index feecefa043..d6e2ede4f3 100644 | |
69 | --- a/src/extension/internal/pdfinput/pdf-parser.cpp | |
70 | +++ b/src/extension/internal/pdfinput/pdf-parser.cpp | |
71 | @@ -30,6 +30,7 @@ | |
72 | #include "Gfx.h" | |
73 | #include "pdf-parser.h" | |
74 | #include "util/units.h" | |
75 | +#include "poppler-transition-api.h" | |
76 | ||
77 | #include "glib/poppler-features.h" | |
78 | #include "goo/gmem.h" | |
79 | @@ -2158,7 +2159,7 @@ void PdfParser::opSetCharSpacing(Object args[], int /*numArgs*/) | |
80 | // TODO not good that numArgs is ignored but args[] is used: | |
81 | void PdfParser::opSetFont(Object args[], int /*numArgs*/) | |
82 | { | |
83 | - GfxFont *font = res->lookupFont(args[0].getName()); | |
84 | + auto font = res->lookupFont(args[0].getName()); | |
85 | ||
86 | if (!font) { | |
87 | // unsetting the font (drawing no text) is better than using the | |
88 | @@ -2179,7 +2180,9 @@ void PdfParser::opSetFont(Object args[], int /*numArgs*/) | |
89 | fflush(stdout); | |
90 | } | |
91 | ||
92 | +#if !POPPLER_CHECK_VERSION(22, 4, 0) | |
93 | font->incRefCnt(); | |
94 | +#endif | |
95 | state->setFont(font, args[1].getNum()); | |
96 | fontChanged = gTrue; | |
97 | } | |
98 | @@ -2373,7 +2376,6 @@ void PdfParser::doShowText(const GooString *s) { | |
99 | #else | |
100 | void PdfParser::doShowText(GooString *s) { | |
101 | #endif | |
102 | - GfxFont *font; | |
103 | int wMode; | |
104 | double riseX, riseY; | |
105 | CharCode code; | |
106 | @@ -2392,7 +2394,7 @@ void PdfParser::doShowText(GooString *s) { | |
107 | #endif | |
108 | int len, n, uLen; | |
109 | ||
110 | - font = state->getFont(); | |
111 | + auto font = state->getFont(); | |
112 | wMode = font->getWMode(); | |
113 | ||
114 | builder->beginString(state); | |
115 | @@ -2445,10 +2447,10 @@ void PdfParser::doShowText(GooString *s) { | |
116 | //out->updateCTM(state, 1, 0, 0, 1, 0, 0); | |
117 | if (false){ /*!out->beginType3Char(state, curX + riseX, curY + riseY, tdx, tdy, | |
118 | code, u, uLen)) {*/ | |
119 | - _POPPLER_CALL_ARGS(charProc, ((Gfx8BitFont *)font)->getCharProc, code); | |
120 | - if ((resDict = ((Gfx8BitFont *)font)->getResources())) { | |
121 | + _POPPLER_CALL_ARGS(charProc, _POPPLER_FONTPTR_TO_GFX8(font)->getCharProc, code); | |
122 | + if (resDict = _POPPLER_FONTPTR_TO_GFX8(font)->getResources()) { | |
123 | pushResources(resDict); | |
124 | - } | |
125 | + } | |
126 | if (charProc.isStream()) { | |
127 | //parse(&charProc, gFalse); // TODO: parse into SVG font | |
128 | } else { | |
129 | diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h | |
130 | index 50b617c25c..dc9e47e45b 100644 | |
131 | --- a/src/extension/internal/pdfinput/poppler-transition-api.h | |
132 | +++ b/src/extension/internal/pdfinput/poppler-transition-api.h | |
133 | @@ -14,6 +14,12 @@ | |
134 | ||
135 | #include <glib/poppler-features.h> | |
136 | ||
137 | +#if POPPLER_CHECK_VERSION(22, 4, 0) | |
138 | +#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr.get()) | |
139 | +#else | |
140 | +#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr) | |
141 | +#endif | |
142 | + | |
143 | #if POPPLER_CHECK_VERSION(22, 3, 0) | |
144 | #define _POPPLER_MAKE_SHARED_PDFDOC(uri) std::make_shared<PDFDoc>(std::make_unique<GooString>(uri)) | |
145 | #else | |
146 | diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp | |
147 | index eede668893..901cc8cddb 100644 | |
148 | --- a/src/extension/internal/pdfinput/svg-builder.cpp | |
149 | +++ b/src/extension/internal/pdfinput/svg-builder.cpp | |
150 | @@ -108,7 +108,6 @@ SvgBuilder::~SvgBuilder() = default; | |
151 | ||
152 | void SvgBuilder::_init() { | |
153 | _font_style = nullptr; | |
154 | - _current_font = nullptr; | |
155 | _font_specification = nullptr; | |
156 | _font_scaling = 1; | |
157 | _need_font_update = true; | |
158 | @@ -1064,11 +1063,8 @@ void SvgBuilder::updateFont(GfxState *state) { | |
159 | _need_font_update = false; | |
160 | updateTextMatrix(state); // Ensure that we have a text matrix built | |
161 | ||
162 | - if (_font_style) { | |
163 | - //sp_repr_css_attr_unref(_font_style); | |
164 | - } | |
165 | _font_style = sp_repr_css_attr_new(); | |
166 | - GfxFont *font = state->getFont(); | |
167 | + auto font = state->getFont(); | |
168 | // Store original name | |
169 | if (font->getName()) { | |
170 | _font_specification = font->getName()->getCString(); | |
171 | @@ -1213,7 +1209,6 @@ void SvgBuilder::updateFont(GfxState *state) { | |
172 | sp_repr_css_set_property(_font_style, "writing-mode", "tb"); | |
173 | } | |
174 | ||
175 | - _current_font = font; | |
176 | _invalidated_style = true; | |
177 | } | |
178 | ||
179 | diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h | |
180 | index fb4e64fa19..e91febd717 100644 | |
181 | --- a/src/extension/internal/pdfinput/svg-builder.h | |
182 | +++ b/src/extension/internal/pdfinput/svg-builder.h | |
183 | @@ -204,7 +204,6 @@ private: | |
184 | std::vector<SvgGraphicsState> _state_stack; | |
185 | ||
186 | SPCSSAttr *_font_style; // Current font style | |
187 | - GfxFont *_current_font; | |
188 | const char *_font_specification; | |
189 | double _font_scaling; | |
190 | bool _need_font_update; | |
191 | -- | |
192 | GitLab | |
193 |