Commit 21dd8a06 authored by Torsten Schönfeld's avatar Torsten Schönfeld

Fix compiling and testing against older versions of cairo

parent a4f81f28
......@@ -28,8 +28,12 @@ get_package (cairo_font_face_t *face)
/* These aren't wrapped yet: */
case CAIRO_FONT_TYPE_WIN32:
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
case CAIRO_FONT_TYPE_QUARTZ:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
case CAIRO_FONT_TYPE_USER:
#endif
package = "Cairo::FontFace";
break;
......@@ -41,7 +45,7 @@ get_package (cairo_font_face_t *face)
return package;
#else
const char *package = cairo_perl_package_table_lookup (pattern);
const char *package = cairo_perl_package_table_lookup (face);
return package ? package : "Cairo::FontFace";
#endif
}
......@@ -84,6 +88,10 @@ cairo_font_face_t_noinc *
cairo_toy_font_face_create (class, const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight)
C_ARGS:
family, slant, weight
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ToyFontFace");
#endif
const char * cairo_toy_font_face_get_family (cairo_font_face_t *font_face);
......@@ -101,6 +109,10 @@ MODULE = Cairo::Font PACKAGE = Cairo::ScaledFont PREFIX = cairo_scaled_font_
cairo_scaled_font_t_noinc * cairo_scaled_font_create (class, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options)
C_ARGS:
font_face, font_matrix, ctm, options
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ScaledFont");
#endif
cairo_status_t cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
......
......@@ -98,9 +98,13 @@ get_package (cairo_surface_t *surface)
case CAIRO_SURFACE_TYPE_WIN32:
case CAIRO_SURFACE_TYPE_BEOS:
case CAIRO_SURFACE_TYPE_DIRECTFB:
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
case CAIRO_SURFACE_TYPE_OS2:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
case CAIRO_SURFACE_TYPE_SCRIPT:
case CAIRO_SURFACE_TYPE_QT:
......
......@@ -321,9 +321,6 @@ if ($have_cairo_1_2) {
CAIRO_SURFACE_TYPE_BEOS
CAIRO_SURFACE_TYPE_DIRECTFB
CAIRO_SURFACE_TYPE_SVG
CAIRO_SURFACE_TYPE_OS2
CAIRO_SURFACE_TYPE_WIN32_PRINTING
CAIRO_SURFACE_TYPE_QUARTZ_IMAGE
/];
$enums{cairo_svg_version_t} = [qw/
......@@ -354,6 +351,7 @@ if ($have_cairo_1_4) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_INVALID_INDEX
CAIRO_STATUS_CLIP_NOT_REPRESENTABLE/],
cairo_surface_type_t => [qw/CAIRO_SURFACE_TYPE_OS2/],
);
push @exports, qw/newSVCairoRectangle
......@@ -365,7 +363,8 @@ if ($have_cairo_1_6) {
cairo_font_type_t => [qw/CAIRO_FONT_TYPE_QUARTZ/],
cairo_status_t => [qw/CAIRO_STATUS_TEMP_FILE_ERROR
CAIRO_STATUS_INVALID_STRIDE/],
cairo_surface_type_t => [qw/CAIRO_SURFACE_TYPE_WIN32_PRINTING
CAIRO_SURFACE_TYPE_QUARTZ_IMAGE/],
);
$enums{cairo_ps_level_t} = [qw/
......
......@@ -62,17 +62,17 @@ my $ctm = Cairo::Matrix->init_identity;
my $font = Cairo::ScaledFont->create ($face, $matrix, $ctm, $options);
isa_ok ($font, 'Cairo::ScaledFont');
$cr->set_scaled_font ($font);
is ($font->status, 'success');
is ($cr->status, 'success');
isa_ok ($font->extents, 'HASH');
isa_ok ($font->glyph_extents ({ index => 1, x => 2, y => 3 }), 'HASH');
SKIP: {
skip 'new stuff', 6
skip 'new stuff', 8
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$cr->set_scaled_font ($font);
is ($font->status, 'success');
is ($cr->status, 'success');
ok (defined $font->get_type);
isa_ok ($font->text_extents('Bla'), 'HASH');
......
......@@ -11,11 +11,17 @@ use strict;
use warnings;
use Cairo;
use Test::More tests => 6;
use Test::More;
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
if (Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 4, 0)) {
plan tests => 6;
} else {
plan skip_all => 'path behavior not predictable on cairo < 1.4';
}
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
my $cr = Cairo::Context->create ($surf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment