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 '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')

View file

@ -45,6 +45,7 @@ extern "C"
#ifdef HAVE_CAIRO
#include <mapnik/cairo_renderer.hpp>
#include <cairo-features.h>
#endif
#include <boost/foreach.hpp>
@ -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<Cairo::Context> context = Cairo::Context::create(surface);
// TODO - expose as user option