check which cairo surfaces are supported

This commit is contained in:
Dane Springmeyer 2012-03-21 15:34:01 -07:00
parent 9c2b3d7144
commit d55ad5a4d2
2 changed files with 24 additions and 0 deletions

View file

@ -73,6 +73,7 @@ if env['THREADING'] == 'multi':
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
if 'icuuc' in env['ICU_LIB_NAME']: if 'icuuc' in env['ICU_LIB_NAME']:
lib_env['LIBS'].append('icudata') lib_env['LIBS'].append('icudata')
lib_env['LIBS'].append('icui18n')
else: else:
if env['INTERNAL_LIBAGG']: if env['INTERNAL_LIBAGG']:
lib_env['LIBS'].insert(0, 'agg') lib_env['LIBS'].insert(0, 'agg')

View file

@ -45,6 +45,7 @@ extern "C"
#ifdef HAVE_CAIRO #ifdef HAVE_CAIRO
#include <mapnik/cairo_renderer.hpp> #include <mapnik/cairo_renderer.hpp>
#include <cairo-features.h>
#endif #endif
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
@ -371,17 +372,39 @@ void save_to_cairo_file(mapnik::Map const& map,
unsigned width = map.width(); unsigned width = map.width();
unsigned height = map.height(); unsigned height = map.height();
if (type == "pdf") if (type == "pdf")
{
#if defined(CAIRO_HAS_PDF_SURFACE)
surface = Cairo::PdfSurface::create(filename,width,height); 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") else if (type == "svg")
{
surface = Cairo::SvgSurface::create(filename,width,height); surface = Cairo::SvgSurface::create(filename,width,height);
}
#endif
#if defined(CAIRO_HAS_PS_SURFACE)
else if (type == "ps") else if (type == "ps")
{
surface = Cairo::PsSurface::create(filename,width,height); surface = Cairo::PsSurface::create(filename,width,height);
}
#endif
#if defined(CAIRO_HAS_IMAGE_SURFACE)
else if (type == "ARGB32") else if (type == "ARGB32")
{
surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,width,height); surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,width,height);
}
else if (type == "RGB24") else if (type == "RGB24")
{
surface = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24,width,height); surface = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24,width,height);
}
#endif
else else
{
throw ImageWriterException("unknown file type: " + type); throw ImageWriterException("unknown file type: " + type);
}
Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create(surface); Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create(surface);
// TODO - expose as user option // TODO - expose as user option