[perl-cairo] Add a binding for cairo_pdf_surface_set_metadata



commit 78e97becb23cd0f6dcb97c6a70bf61a64d603099
Author: Johan Vromans <jv cpan org>
Date:   Wed Sep 11 21:35:32 2019 +0200

    Add a binding for cairo_pdf_surface_set_metadata

 CairoSurface.xs  |  6 ++++++
 Makefile.PL      | 16 ++++++++++++++++
 lib/Cairo.pm     | 10 ++++++++++
 t/CairoSurface.t | 14 ++++++++++++--
 4 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/CairoSurface.xs b/CairoSurface.xs
index 9a9d177..11468ec 100644
--- a/CairoSurface.xs
+++ b/CairoSurface.xs
@@ -580,6 +580,12 @@ cairo_pdf_surface_version_to_string (...)
 
 #endif
 
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
+
+void cairo_pdf_surface_set_metadata (cairo_surface_t *surface, cairo_pdf_metadata_t metadata, const 
char_utf8 * utf8);
+
+#endif
+
 #endif
 
 # --------------------------------------------------------------------------- #
diff --git a/Makefile.PL b/Makefile.PL
index d8e056b..d7a6d49 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -325,6 +325,7 @@ my $have_cairo_1_4 = ExtUtils::PkgConfig->atleast_version("cairo", "1.4.0");
 my $have_cairo_1_6 = ExtUtils::PkgConfig->atleast_version("cairo", "1.6.0");
 my $have_cairo_1_8 = ExtUtils::PkgConfig->atleast_version("cairo", "1.8.0");
 my $have_cairo_1_10 = ExtUtils::PkgConfig->atleast_version("cairo", "1.10.0");
+my $have_cairo_1_16 = ExtUtils::PkgConfig->atleast_version("cairo", "1.16.0");
 
 if ($have_cairo_1_2) {
        add_new_enum_values(
@@ -500,6 +501,21 @@ if ($have_cairo_1_10) {
        $enums{cairo_region_overlap_t} = [];
 }
 
+if ($have_cairo_1_16) {
+       $enums{cairo_pdf_metadata_t} = [qw/
+               CAIRO_PDF_METADATA_
+               CAIRO_PDF_METADATA_TITLE
+               CAIRO_PDF_METADATA_AUTHOR
+               CAIRO_PDF_METADATA_SUBJECT
+               CAIRO_PDF_METADATA_KEYWORDS
+               CAIRO_PDF_METADATA_CREATOR
+               CAIRO_PDF_METADATA_CREATE_DATE
+               CAIRO_PDF_METADATA_MOD_DATE
+       /];
+} else {
+       $enums{cairo_pdf_metadata_t} = [];
+}
+
 # --------------------------------------------------------------------------- #
 
 my %object_guards = (
diff --git a/lib/Cairo.pm b/lib/Cairo.pm
index c96be8d..0a8548b 100644
--- a/lib/Cairo.pm
+++ b/lib/Cairo.pm
@@ -1509,6 +1509,16 @@ For hysterical reasons, you can also use the following syntax:
 
 =back
 
+=item $surface->set_metadata($name, $value) [1.16]
+
+=over
+
+=item $name: string
+
+=item $value: string
+
+=back
+
 =back
 
 =cut
diff --git a/t/CairoSurface.t b/t/CairoSurface.t
index 48ed134..c48f1cf 100644
--- a/t/CairoSurface.t
+++ b/t/CairoSurface.t
@@ -12,7 +12,7 @@ use warnings;
 
 use Config; # for byteorder
 
-use Test::More tests => 88;
+use Test::More tests => 89;
 
 use constant IMG_WIDTH => 256;
 use constant IMG_HEIGHT => 256;
@@ -216,7 +216,7 @@ SKIP: {
 }
 
 SKIP: {
-       skip 'pdf surface', 13
+       skip 'pdf surface', 14
                unless Cairo::HAS_PDF_SURFACE;
 
        my $surf = Cairo::PdfSurface->create ('tmp.pdf', IMG_WIDTH, IMG_HEIGHT);
@@ -268,6 +268,16 @@ SKIP: {
                like (Cairo::PdfSurface->version_to_string('1-4'), qr/1\.4/);
        }
 
+       SKIP: {
+               skip 'new stuff', 1
+                       unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 16, 0);
+
+               $surf->set_metadata("title","Testing metadata");
+               $surf->set_metadata("author","Johan Vromans");
+               $surf->set_metadata("subject","cairo_pdf_set_metadata");
+               ok(1);  # No get_metadata, so assume OK if we're still alive
+       }
+
        unlink 'tmp.pdf';
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]