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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
|
Patches from Étoilé:
- Add support Poppler 0.5
- Fix distorted colours in splash renderer
- Add missing check for fontconfig
--- popplerkit.framework.orig/bindings/GNUmakefile
+++ popplerkit.framework/bindings/GNUmakefile
@@ -44,4 +44,12 @@
bindings_C_FILES += poppler_cairo_img_renderer.c
endif
+ifeq ($(POPPLER_0_4), YES)
+ bindings_CFLAGS += -DPOPPLER_0_4
+endif
+
+ifeq ($(POPPLER_0_5), YES)
+ bindings_CFLAGS += -DPOPPLER_0_5
+endif
+
include $(GNUSTEP_MAKEFILES)/subproject.make
--- popplerkit.framework.orig/bindings/poppler.cc
+++ popplerkit.framework/bindings/poppler.cc
@@ -124,7 +124,9 @@
}
globalParams = new GlobalParams(NULL);
+#ifdef POPPLER_0_4
globalParams->setupBaseFontsFc(NULL);
+#endif
//dump_fonts(FcConfigGetCurrent());
fprintf(stderr, "poppler library initialized\n"); fflush(stderr);
}
--- popplerkit.framework.orig/bindings/poppler_cairo_img_renderer.cc
+++ popplerkit.framework/bindings/poppler_cairo_img_renderer.cc
@@ -49,13 +49,25 @@
if (rotate == 90 || rotate == 270)
{
+#ifdef POPPLER_0_4
width = MAX((int)(page->getHeight() * scale + 0.5), 1);
height = MAX((int)(page->getWidth() * scale + 0.5), 1);
+#endif
+#ifdef POPPLER_0_5
+ width = MAX((int)(page->getMediaHeight() * scale + 0.5), 1);
+ height = MAX((int)(page->getMediaWidth() * scale + 0.5), 1);
+#endif
}
else
{
+#ifdef POPPLER_0_4
width = MAX((int)(page->getWidth() * scale + 0.5), 1);
height = MAX((int)(page->getHeight() * scale + 0.5), 1);
+#endif
+#ifdef POPPLER_0_5
+ width = MAX((int)(page->getMediaWidth() * scale + 0.5), 1);
+ height = MAX((int)(page->getMediaHeight() * scale + 0.5), 1);
+#endif
}
int rowstride = width * 4;
@@ -64,7 +76,11 @@
cairo_surface_t* surface = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, rowstride);
+#ifdef POPPLER_0_5
+ output_dev->device->setCairo(cairo_create(surface));
+#else
output_dev->device->setSurface(surface);
+#endif
output_dev->surface = surface;
output_dev->data = data;
}
@@ -122,6 +138,9 @@
SYNCHRONIZED(PAGE(poppler_page)->displaySlice(CAIRO_DEV_IMG(output_dev)->device,
(double)hDPI, (double)vDPI,
rotate,
+#ifdef POPPLER_0_5
+ gTrue, // use MediaBox
+#endif
gTrue, // Crop
(int)sliceX, (int)sliceY,
(int)sliceW, (int)sliceH,
--- popplerkit.framework.orig/bindings/poppler_page.cc
+++ popplerkit.framework/bindings/poppler_page.cc
@@ -66,7 +66,14 @@
return -1;
}
+
+#ifdef POPPLER_0_4
return PAGE(poppler_page)->getWidth();
+#endif
+#ifdef POPPLER_0_5
+ return PAGE(poppler_page)->getMediaWidth();
+#endif
+
}
double poppler_page_get_height(void* poppler_page)
@@ -76,5 +83,11 @@
return -1;
}
+#ifdef POPPLER_0_4
return PAGE(poppler_page)->getHeight();
+#endif
+#ifdef POPPLER_0_5
+ return PAGE(poppler_page)->getMediaHeight();
+#endif
+
}
--- popplerkit.framework.orig/bindings/poppler_splash_renderer.cc
+++ popplerkit.framework/bindings/poppler_splash_renderer.cc
@@ -35,8 +35,17 @@
{
BEGIN_SYNCHRONIZED;
SplashColor white;
+#ifdef POPPLER_0_4
white.rgb8 = splashMakeRGB8(bg_red, bg_green, bg_blue);
void* splashDevice = new SplashOutputDev(splashModeRGB8, gFalse, white);
+#endif
+#ifdef POPPLER_0_5
+ white[0] = bg_red;
+ white[1] = bg_green;
+ white[2] = bg_blue;
+ // I'm not sure what bitmapRowPad should be, 1 is just a guess.
+ void* splashDevice = new SplashOutputDev(splashModeRGB8, 1, gFalse, white);
+#endif
END_SYNCHRONIZED;
return splashDevice;
@@ -77,6 +86,9 @@
SYNCHRONIZED(PAGE(poppler_page)->displaySlice(SPLASH_DEV(output_dev),
(double)hDPI, (double)vDPI,
rotate,
+#ifdef POPPLER_0_5
+ gTrue, // useMediaBox
+#endif
gTrue, // Crop
(int)sliceX, (int)sliceY,
(int)sliceW, (int)sliceH,
@@ -109,22 +121,39 @@
return 0;
}
+#ifdef POPPLER_0_4
SplashRGB8* rgb8;
+#endif
+#ifdef POPPLER_0_5
+ SplashColorPtr color;
+#endif
unsigned char* dataPtr;
+#ifdef POPPLER_0_4
rgb8 = SPLASH_BITMAP(bitmap)->getDataPtr().rgb8;
+#endif
+#ifdef POPPLER_0_5
+ color = SPLASH_BITMAP(bitmap)->getDataPtr();
+#endif
dataPtr = *data;
for (int row = 0; row < SPLASH_BITMAP(bitmap)->getHeight(); row++)
{
for (int col = 0; col < SPLASH_BITMAP(bitmap)->getWidth(); col++)
{
+#ifdef POPPLER_0_4
*dataPtr++ = splashRGB8R(*rgb8);
*dataPtr++ = splashRGB8G(*rgb8);
*dataPtr++ = splashRGB8B(*rgb8);
++rgb8;
+#endif
+#ifdef POPPLER_0_5
+ *dataPtr++ = splashRGB8R(color);
+ *dataPtr++ = splashRGB8G(color);
+ *dataPtr++ = splashRGB8B(color);
+ color = color + 3;
+#endif
}
}
-
return 1;
}
--- popplerkit.framework.orig/bindings/poppler_text.cc
+++ popplerkit.framework/bindings/poppler_text.cc
@@ -49,8 +49,12 @@
if (!text_device || !poppler_page || !poppler_document)
return 0;
- SYNCHRONIZED(PAGE(poppler_page)->display(TEXT_DEV(text_device), hDPI, vDPI, rotate, crop,
- NULL, PDF_DOC(poppler_document)->getCatalog()));
+ SYNCHRONIZED(PAGE(poppler_page)->display(TEXT_DEV(text_device),
+ hDPI, vDPI, rotate,
+#ifdef POPPLER_0_5
+ gTrue, // useMediaBox
+#endif
+ crop, NULL, PDF_DOC(poppler_document)->getCatalog()));
return 1;
}
@@ -66,6 +70,9 @@
int result = TEXT_DEV(text_device)->findText(text_utf32, text_len,
start_at_top, stop_at_bottom,
start_at_last, stop_at_last,
+#ifdef POPPLER_0_5
+ gTrue, gFalse,
+#endif
x_min, y_min, x_max, y_max);
END_SYNCHRONIZED;
--- popplerkit.framework.orig/config.sh
+++ popplerkit.framework/config.sh
@@ -15,6 +15,14 @@
POPPLER_CFLAGS=`${PKG_CONFIG} --cflags poppler`
POPPLER_LIBS="${POPPLER_LDFLAGS} `${PKG_CONFIG} --libs poppler`"
+# fontconfig
+${PKG_CONFIG} --exists fontconfig
+if [ $? -ne 0 ]; then
+ echo "fontconfig library required but not found!"
+ exit 1
+fi
+FONTCONFIG_LIBS=`${PKG_CONFIG} --libs fontconfig`
+
# poppler splash device
${PKG_CONFIG} --exists poppler-splash
if [ $? -ne 0 ]; then
@@ -30,16 +38,31 @@
echo "poppler-cairo not found, building without cairo rendering"
HAVE_CAIRO="NO"
else
- HAVE_CAIRO="YES"
- POPPLER_CFLAGS="${POPPLER_CFLAGS} `${PKG_CONFIG} --cflags poppler-cairo`"
- POPPLER_LIBS="${POPPLER_LDFLAGS} `${PKG_CONFIG} --libs poppler-cairo`"
+# Disable Cairo support for now to avoid most of problem
+# HAVE_CAIRO="YES"
+# POPPLER_CFLAGS="${POPPLER_CFLAGS} `${PKG_CONFIG} --cflags poppler-cairo`"
+# POPPLER_LIBS="${POPPLER_LDFLAGS} `${PKG_CONFIG} --libs poppler-cairo`"
+ HAVE_CAIRO="NO"
+fi
+
+# check poppler version
+${PKG_CONFIG} --atleast-version=0.4 poppler
+if [ $? -eq 0 ]; then
+ POPPLER_VERSION="POPPLER_0_4"
+else
+ echo "PopplerKit does not support this version of poppler"
+ exit 1
+fi
+
+${PKG_CONFIG} --atleast-version=0.5 poppler
+if [ $? -eq 0 ]; then
+ POPPLER_VERSION="POPPLER_0_5"
fi
# include freetype, just to be sure
${PKG_CONFIG} --exists freetype2
if [ $? -eq 0 ]; then
FT_CFLAGS=`${PKG_CONFIG} --cflags freetype2`
- FT_LIBS=`${PKG_CONFIG} --libs freetype2`
else
FT_CONFIG=`which freetype-config 2>/dev/null`
if [ -z "${FT_CONFIG}" ]; then
@@ -47,17 +70,19 @@
exit 1
fi
FT_CFLAGS=`${FT_CONFIG} --cflags`
- FT_LIBS=`${FT_CONFIG} --libs`
fi
# write config.make
echo "# config.make, generated at `date`" >config.make
echo "POPPLER_CFLAGS=${POPPLER_CFLAGS}" >>config.make
echo "POPPLER_LIBS=${POPPLER_LIBS}" >>config.make
+echo "${POPPLER_VERSION}=YES" >> config.make
echo "FT_CFLAGS=${FT_CFLAGS}" >> config.make
-echo "FT_LIBS=${FT_LIBS}" >> config.make
-echo "ADDITIONAL_CFLAGS=\$(POPPLER_CFLAGS) \$(FT_CFLAGS)" >> config.make
-echo "ADDITIONAL_LDFLAGS=\$(POPPLER_LIBS) \$(POPPLER_LIBS)" >> config.make
+echo "FONTCONFIG_LIBS=${FONTCONFIG_LIBS}" >> config.make
+echo "ADDITIONAL_CFLAGS+=\$(POPPLER_CFLAGS) \$(FT_CFLAGS)" >> config.make
+echo "LIBRARIES_DEPEND_UPON=\$(OBJC_LIBS) \$(FND_LIBS) \$(GUI_LIBS) \$(FONTCONFIG_LIBS) \$(POPPLER_LIBS)" >> config.make
+# we add -I/usr/X11R6/include for older FreeBSD version.
+echo "ADDITIONAL_INCLUDE_DIRS += -I/usr/X11R6/include" >> config.make
echo "HAVE_CAIRO=${HAVE_CAIRO}" >>config.make
exit 0
|