[cairo-commit] cairo-perl Cairo.pm, 1.29, 1.30 Cairo.xs, 1.21, 1.22 CairoFt.xs, NONE, 1.1 ChangeLog, 1.76, 1.77 Makefile.PL, 1.28, 1.29 cairo-perl.h, 1.12, 1.13 cairo-perl.typemap, 1.5, 1.6

Torsten Schoenfeld commit at pdx.freedesktop.org
Wed Oct 24 09:32:07 PDT 2007


Committed by: tsch

Update of /cvs/cairo/cairo-perl
In directory kemper:/tmp/cvs-serv3018

Modified Files:
	Cairo.pm Cairo.xs ChangeLog Makefile.PL cairo-perl.h 
	cairo-perl.typemap 
Added Files:
	CairoFt.xs 
Log Message:
	* Cairo.pm
	* Cairo.xs
	* CairoFt.xs
	* Makefile.PL
	* cairo-perl.h
	* cairo-perl.typemap
	* examples/freetype-font.pl
	* t/CairoFt.t: Add support for part of cairo's FreeType
	integration API.  Currently, that's just
	Cairo::FtFontFace::create, which lets you create a cairo font face
	from a FreeType font face.


Index: Cairo.pm
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- Cairo.pm	13 Oct 2007 22:42:19 -0000	1.29
+++ Cairo.pm	24 Oct 2007 16:32:04 -0000	1.30
@@ -1031,6 +1031,35 @@
 
 # --------------------------------------------------------------------------- #
 
+=head3 FreeType Fonts -- Font support for FreeType
+
+If your cairo library supports it, the FreeType integration allows you to load
+font faces from font files.  You can query for this capability with
+C<Cairo::HAS_FT_FONT>.  To actually use this, you'll need the L<Font::FreeType>
+module.
+
+=head4 my $face = Cairo::FtFontFace->create ($ft_face, $load_flags=0)
+
+=over
+
+=item $ft_face: I<Font::FreeType::Face>
+
+=item $load_flags: integer
+
+=back
+
+This method allows you to create a I<Cairo::FontFace> from a
+I<Font::FreeType::Face>.  To obtain the latter, you can for example load it
+from a file:
+
+  my $file = '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf';
+  my $ft_face = Font::FreeType->new->face ($file);
+  my $face = Cairo::FtFontFace->create ($ft_face);
+
+=cut
+
+# --------------------------------------------------------------------------- #
+
 =head2 Utilities
 
 =head3 Version Information -- Run-time and compile-time version checks.

Index: Cairo.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.xs,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Cairo.xs	30 Sep 2007 12:54:31 -0000	1.21
+++ Cairo.xs	24 Oct 2007 16:32:05 -0000	1.22
@@ -685,6 +685,17 @@
 	RETVAL
 
 bool
+HAS_FT_FONT ()
+    CODE:
+#ifdef CAIRO_HAS_FT_FONT
+	RETVAL = TRUE;
+#else
+	RETVAL = FALSE;
+#endif
+    OUTPUT:
+	RETVAL
+
+bool
 HAS_PNG_FUNCTIONS ()
     CODE:
 #ifdef CAIRO_HAS_PNG_FUNCTIONS

--- NEW FILE: CairoFt.xs ---
/*
 * Copyright (c) 2007 by the cairo perl team (see the file README)
 *
 * Licensed under the LGPL, see LICENSE file for more information.
 *
 * $Header: /cvs/cairo/cairo-perl/CairoFt.xs,v 1.1 2007-10-24 16:32:05 tsch Exp $
 */

#include <cairo-perl.h>

MODULE = Cairo::Ft	PACKAGE = Cairo::FtFontFace PREFIX = cairo_ft_font_face_

# cairo_font_face_t * cairo_ft_font_face_create_for_ft_face (FT_Face face, int load_flags);
cairo_font_face_t_noinc *
cairo_ft_font_face_create (class, FT_Face face, int load_flags=0)
    CODE:
	RETVAL = cairo_ft_font_face_create_for_ft_face (face, load_flags);
    OUTPUT:
	RETVAL

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-perl/ChangeLog,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- ChangeLog	24 Oct 2007 16:15:23 -0000	1.76
+++ ChangeLog	24 Oct 2007 16:32:05 -0000	1.77
@@ -3,6 +3,18 @@
 	* t/CairoFont.t: Really don't use the hash-ref variant of the
 	constant pragma this time.
 
+	* Cairo.pm
+	* Cairo.xs
+	* CairoFt.xs
+	* Makefile.PL
+	* cairo-perl.h
+	* cairo-perl.typemap
+	* examples/freetype-font.pl
+	* t/CairoFt.t: Add support for part of cairo's FreeType
+	integration API.  Currently, that's just
+	Cairo::FtFontFace::create, which lets you create a cairo font face
+	from a FreeType font face.
+
 2007-10-18  Torsten Schoenfeld  <kaffeetisch at gmx.de>
 
 	* t/Cairo.t

Index: Makefile.PL
===================================================================
RCS file: /cvs/cairo/cairo-perl/Makefile.PL,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- Makefile.PL	13 Oct 2007 21:23:16 -0000	1.28
+++ Makefile.PL	24 Oct 2007 16:32:05 -0000	1.29
@@ -297,7 +297,23 @@
 
 MakeHelper::do_enums (\%enums, \%enum_guards);
 
-my @xs_files = <*.xs>;
+my @xs_files = qw(
+	Cairo.xs
+	CairoFont.xs
+	CairoMatrix.xs
+	CairoPath.xs
+	CairoPattern.xs
+	CairoSurface.xs
+);
+
+my $have_cairo_ft = !system qw(pkg-config --exists --silence-errors cairo-ft);
+if ($have_cairo_ft) {
+	print "Compiling Cairo with FreeType support\n";
+	push @xs_files, 'CairoFt.xs';
+	my %ft_cfg = ExtUtils::PkgConfig->find ('cairo-ft');
+	$cairo_cfg{cflags} .= ' '.$ft_cfg{cflags};
+	$cairo_cfg{libs} .= ' '.$ft_cfg{libs};
+}
 
 MakeHelper::write_boot (
 	xs_files => \@xs_files,

Index: cairo-perl.h
===================================================================
RCS file: /cvs/cairo/cairo-perl/cairo-perl.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cairo-perl.h	6 May 2007 11:28:37 -0000	1.12
+++ cairo-perl.h	24 Oct 2007 16:32:05 -0000	1.13
@@ -32,6 +32,10 @@
 # include <cairo-svg.h>
 #endif
 
+#if CAIRO_HAS_FT_FONT
+# include <cairo-ft.h>
+#endif
+
 #include <cairo-perl-auto.h>
 
 /*

Index: cairo-perl.typemap
===================================================================
RCS file: /cvs/cairo/cairo-perl/cairo-perl.typemap,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-perl.typemap	9 Sep 2007 19:56:21 -0000	1.5
+++ cairo-perl.typemap	24 Oct 2007 16:32:05 -0000	1.6
@@ -19,6 +19,9 @@
 cairo_glyph_t *		T_CAIRO_GLYPH
 cairo_path_t *		T_CAIRO_PATH
 
+FT_Face			T_FT_FACE
+
+
 INPUT
 
 T_CAIRO_GLYPH
@@ -27,6 +30,13 @@
 T_CAIRO_PATH
 	$var = SvCairoPath ($arg);
 
+T_FT_FACE
+	if (sv_isobject ($arg) && sv_derived_from ($arg, \"Font::FreeType::Face\")) {
+		$var = ($type) SvIV ((SV *) SvRV ($arg));
+	} else {
+		croak(\"$var is not of type Font::FreeType::Face\");
+	}
+
 OUTPUT
 
 T_CAIRO_FONT_EXTENTS



More information about the cairo-commit mailing list