1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
From 5c4c6d116dae5250d75d34a45f0d9220824d2e20 Mon Sep 17 00:00:00 2001
From: KrIr17 <elendil.krir17@gmail.com>
Date: Sun, 9 Feb 2025 22:52:53 +0530
Subject: [PATCH] Fix building with poppler 25.02.0
1. `getCodeToGIDMap`, `getCIDToGID`, `getCIDToGIDMap` are now `std::vector`
2. `pdfDocEncodingToUTF16` returns an `std::string`
---
.../pdfinput/poppler-cairo-font-engine.cpp | 50 +++++++++++++++----
.../pdfinput/poppler-transition-api.h | 20 +++++---
3 files changed, 63 insertions(+), 16 deletions(-)
diff --git a/src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp b/src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp
index 728b1d1aac4..bd1d4e49367 100644
--- a/src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp
+++ b/src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp
@@ -405,14 +405,22 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
break;
case fontCIDType2:
case fontCIDType2OT:
+#if POPPLER_CHECK_VERSION(25,2,0)
+ if (!gfxcid->getCIDToGID().empty()) {
+ const auto src = gfxcid->getCIDToGID();
+ codeToGID = std::move(src);
+ }
+#else
if (gfxcid->getCIDToGID()) {
n = gfxcid->getCIDToGIDLen();
if (n) {
- const int *src = gfxcid->getCIDToGID();
+ const auto src = gfxcid->getCIDToGID();
codeToGID.reserve(n);
codeToGID.insert(codeToGID.begin(), src, src + n);
}
- } else {
+ }
+#endif
+ else {
#if POPPLER_CHECK_VERSION(22, 1, 0)
std::unique_ptr<FoFiTrueType> ff;
#else
@@ -427,13 +435,18 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
goto err2;
}
#if POPPLER_CHECK_VERSION(22, 1, 0)
- int *src = gfxcid->getCodeToGIDMap(ff.get(), &n);
+ auto src = gfxcid->_POPPLER_GET_CODE_TO_GID_MAP(ff.get(), &n);
#else
- int *src = gfxcid->getCodeToGIDMap(ff, &n);
+ auto src = gfxcid->_POPPLER_GET_CODE_TO_GID_MAP(ff, &n);
#endif
+
+#if POPPLER_CHECK_VERSION(25,2,0)
+ codeToGID = std::move(src);
+#else
codeToGID.reserve(n);
codeToGID.insert(codeToGID.begin(), src, src + n);
gfree(src);
+#endif
}
/* Fall through */
case fontTrueType:
@@ -455,13 +468,17 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
/* This might be set already for the CIDType2 case */
if (fontType == fontTrueType || fontType == fontTrueTypeOT) {
#if POPPLER_CHECK_VERSION(22, 1, 0)
- int *src = gfx8bit->getCodeToGIDMap(ff.get());
+ auto src = gfx8bit->getCodeToGIDMap(ff.get());
#else
- int *src = gfx8bit->getCodeToGIDMap(ff);
+ auto src = gfx8bit->getCodeToGIDMap(ff);
#endif
+#if POPPLER_CHECK_VERSION(25,2,0)
+ codeToGID = std::move(src);
+#else
codeToGID.reserve(256);
codeToGID.insert(codeToGID.begin(), src, src + 256);
gfree(src);
+#endif
}
font_face = getFreeTypeFontFace(fontEngine, lib, fileName, std::move(font_data));
if (!font_face) {
@@ -479,10 +496,14 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
ff1c = FoFiType1C::load(fileName.c_str());
}
if (ff1c) {
- int *src = ff1c->getCIDToGIDMap(&n);
+ auto src = ff1c->_POPPLER_GET_CID_TO_GID_MAP(&n);
+#if POPPLER_CHECK_VERSION(25,2,0)
+ codeToGID = std::move(src);
+#else
codeToGID.reserve(n);
codeToGID.insert(codeToGID.begin(), src, src + n);
gfree(src);
+#endif
delete ff1c;
}
}
@@ -495,14 +516,21 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
break;
case fontCIDType0COT:
+#if POPPLER_CHECK_VERSION(25,2,0)
+ if (!gfxcid->getCIDToGID().empty()) {
+ const auto src = gfxcid->getCIDToGID();
+ codeToGID = std::move(src);
+ }
+#else
if (gfxcid->getCIDToGID()) {
n = gfxcid->getCIDToGIDLen();
if (n) {
- const int *src = gfxcid->getCIDToGID();
+ const auto src = gfxcid->getCIDToGID();
codeToGID.reserve(n);
codeToGID.insert(codeToGID.begin(), src, src + n);
}
}
+#endif
if (codeToGID.empty()) {
if (!useCIDs) {
@@ -518,10 +546,14 @@ CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
}
if (ff) {
if (ff->isOpenTypeCFF()) {
- int *src = ff->getCIDToGIDMap(&n);
+ auto src = ff1c->_POPPLER_GET_CID_TO_GID_MAP(&n);
+#if POPPLER_CHECK_VERSION(25,2,0)
+ codeToGID = std::move(src);
+#else
codeToGID.reserve(n);
codeToGID.insert(codeToGID.begin(), src, src + n);
gfree(src);
+#endif
}
}
}
diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
index b7a54828e74..a67132ba6bd 100644
--- a/src/extension/internal/pdfinput/poppler-transition-api.h
+++ b/src/extension/internal/pdfinput/poppler-transition-api.h
@@ -15,6 +15,20 @@
#include <glib/poppler-features.h>
#include <poppler/UTF.h>
+#if POPPLER_CHECK_VERSION(25,2,0)
+#define _POPPLER_GET_CODE_TO_GID_MAP(ff, len) getCodeToGIDMap(ff)
+#define _POPPLER_GET_CID_TO_GID_MAP(len) getCIDToGIDMap()
+#else
+#define _POPPLER_GET_CODE_TO_GID_MAP(ff, len) getCodeToGIDMap(ff, len)
+#define _POPPLER_GET_CID_TO_GID_MAP(len) getCIDToGIDMap(len)
+#endif
+
+#if POPPLER_CHECK_VERSION(24,12,0)
+#define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode, hasAlpha)
+#else
+#define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode)
+#endif
+
#if POPPLER_CHECK_VERSION(24, 10, 0)
#define _POPPLER_CONSUME_UNIQPTR_ARG(value) std::move(value)
#else
@@ -39,12 +53,6 @@
#define _POPPLER_FUNCTION_TYPE_STITCHING 3
#endif
-#if POPPLER_CHECK_VERSION(24,12,0)
-#define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode, hasAlpha)
-#else
-#define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode)
-#endif
-
#if POPPLER_CHECK_VERSION(22, 4, 0)
#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr.get())
#else
--
GitLab
|