[perl-Cairo] Wrap cairo_scaled_font_text_to_glyphs and cairo_scaled_font_get_scale_matrix
- From: Torsten Schönfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-Cairo] Wrap cairo_scaled_font_text_to_glyphs and cairo_scaled_font_get_scale_matrix
- Date: Sun, 16 May 2010 20:18:28 +0000 (UTC)
commit dc7f14a4bd14684ce1e16faca78896d503f7a3e9
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date: Sun May 16 22:12:22 2010 +0200
Wrap cairo_scaled_font_text_to_glyphs and cairo_scaled_font_get_scale_matrix
CairoFont.xs | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/CairoFont.t | 18 ++++++++++++++++-
2 files changed, 75 insertions(+), 1 deletions(-)
---
diff --git a/CairoFont.xs b/CairoFont.xs
index e5f55ac..1c5dfe0 100644
--- a/CairoFont.xs
+++ b/CairoFont.xs
@@ -81,6 +81,49 @@ cairo_text_extents_t * cairo_scaled_font_glyph_extents (cairo_scaled_font_t *sca
OUTPUT:
RETVAL
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
+
+##cairo_status_t cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, double x, double y, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *cluster_flags);
+void
+cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, double x, double y, SV *utf8_sv)
+ PREINIT:
+ const char *utf8;
+ STRLEN utf8_len;
+ cairo_glyph_t *glyphs = NULL;
+ int num_glyphs;
+ cairo_text_cluster_t *clusters = NULL;
+ int num_clusters;
+ cairo_text_cluster_flags_t cluster_flags;
+ cairo_status_t status;
+ PPCODE:
+ utf8 = SvPV (utf8_sv, utf8_len);
+ status = cairo_scaled_font_text_to_glyphs (
+ scaled_font,
+ x, y,
+ utf8, utf8_len,
+ &glyphs, &num_glyphs,
+ &clusters, &num_clusters, &cluster_flags);
+ PUSHs (sv_2mortal (newSVCairoStatus (status)));
+ if (CAIRO_STATUS_SUCCESS == status) {
+ AV *glyphs_av, *clusters_av;
+ int i;
+ glyphs_av = newAV ();
+ for (i = 0; i < num_glyphs; i++)
+ av_push (glyphs_av, newSVCairoGlyph (&glyphs[i]));
+ cairo_glyph_free (glyphs);
+ clusters_av = newAV ();
+ for (i = 0; i < num_clusters; i++)
+ av_push (clusters_av, newSVCairoTextCluster (&clusters[i]));
+ cairo_text_cluster_free (clusters);
+ EXTEND (SP, 4);
+ PUSHs (sv_2mortal (newRV_noinc ((SV *) glyphs_av)));
+ PUSHs (sv_2mortal (newRV_noinc ((SV *) clusters_av)));
+ PUSHs (sv_2mortal (newSVCairoTextClusterFlags (cluster_flags)));
+ }
+
+
+#endif
+
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_font_face_t * cairo_scaled_font_get_font_face (cairo_scaled_font_t *scaled_font);
@@ -115,6 +158,21 @@ cairo_font_options_t * cairo_scaled_font_get_font_options (cairo_scaled_font_t *
#endif
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
+
+##void cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t *scaled_font, cairo_matrix_t *scale_matrix);
+cairo_matrix_t *
+cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t *scaled_font)
+ PREINIT:
+ cairo_matrix_t matrix;
+ CODE:
+ cairo_scaled_font_get_scale_matrix (scaled_font, &matrix);
+ RETVAL = cairo_perl_copy_matrix (&matrix);
+ OUTPUT:
+ RETVAL
+
+#endif
+
void DESTROY (cairo_scaled_font_t * font)
CODE:
cairo_scaled_font_destroy (font);
diff --git a/t/CairoFont.t b/t/CairoFont.t
index 0558943..e596a1e 100644
--- a/t/CairoFont.t
+++ b/t/CairoFont.t
@@ -9,8 +9,9 @@
use strict;
use warnings;
+use utf8;
-use Test::More tests => 20;
+use Test::More tests => 23;
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
@@ -61,7 +62,9 @@ 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');
@@ -79,3 +82,16 @@ SKIP: {
isa_ok ($font->get_ctm, 'Cairo::Matrix');
isa_ok ($font->get_font_options, 'Cairo::FontOptions');
}
+
+SKIP: {
+ skip 'new stuff', 2
+ unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 8, 0);
+
+ isa_ok ($font->get_scale_matrix, 'Cairo::Matrix');
+
+ my $text = 'æſðÄ?Å?';
+ my ($status, $glyphs, $clusters, $flags) =
+ $font->text_to_glyphs (5, 10, $text);
+ $cr->show_text_glyphs ($text, $glyphs, $clusters, $flags);
+ is ($cr->status, 'success');
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]