From d55ad5a4d21c4ae0541aa056151df2aca69946fc Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 21 Mar 2012 15:34:01 -0700 Subject: [PATCH] check which cairo surfaces are supported --- src/build.py | 1 + src/image_util.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/build.py b/src/build.py index 59bf949ca..34ba537d1 100644 --- a/src/build.py +++ b/src/build.py @@ -73,6 +73,7 @@ if env['THREADING'] == 'multi': if env['RUNTIME_LINK'] == 'static': if 'icuuc' in env['ICU_LIB_NAME']: lib_env['LIBS'].append('icudata') + lib_env['LIBS'].append('icui18n') else: if env['INTERNAL_LIBAGG']: lib_env['LIBS'].insert(0, 'agg') diff --git a/src/image_util.cpp b/src/image_util.cpp index 5b3b46454..35ccb4ba1 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -45,6 +45,7 @@ extern "C" #ifdef HAVE_CAIRO #include +#include #endif #include @@ -371,17 +372,39 @@ void save_to_cairo_file(mapnik::Map const& map, unsigned width = map.width(); unsigned height = map.height(); if (type == "pdf") + { +#if defined(CAIRO_HAS_PDF_SURFACE) surface = Cairo::PdfSurface::create(filename,width,height); + throw ImageWriterException("PDFSurface not supported in the cairo backend"); +#endif + } +#if defined(CAIRO_HAS_SVG_SURFACE) else if (type == "svg") + { surface = Cairo::SvgSurface::create(filename,width,height); + } +#endif +#if defined(CAIRO_HAS_PS_SURFACE) else if (type == "ps") + { surface = Cairo::PsSurface::create(filename,width,height); + } +#endif +#if defined(CAIRO_HAS_IMAGE_SURFACE) else if (type == "ARGB32") + { surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,width,height); + } else if (type == "RGB24") + { surface = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24,width,height); + } +#endif else + { throw ImageWriterException("unknown file type: " + type); + } + Cairo::RefPtr context = Cairo::Context::create(surface); // TODO - expose as user option