File: CairoFt.xs

package info (click to toggle)
libcairo-perl 1.109-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 732 kB
  • sloc: perl: 3,313; ansic: 89; makefile: 11
file content (48 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * Copyright (c) 2007 by the cairo perl team (see the file README)
 *
 * Licensed under the LGPL, see LICENSE file for more information.
 *
 * $Id$
 */

#include <cairo-perl.h>
#include <cairo-perl-private.h>

static const cairo_user_data_key_t face_key;

static void
face_destroy (void *face)
{
	SvREFCNT_dec ((SV *) face);
}

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

BOOT:
	cairo_perl_set_isa ("Cairo::FtFontFace", "Cairo::FontFace");

# 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, SV *face, int load_flags=0)
    PREINIT:
	FT_Face real_face = NULL;
	cairo_status_t status;
    CODE:
	if (sv_isobject (face) && sv_derived_from (face, "Font::FreeType::Face")) {
		real_face = (FT_Face) SvIV ((SV *) SvRV (face));
	} else {
		croak("'%s' is not of type Font::FreeType::Face",
		      SvPV_nolen (face));
	}
	RETVAL = cairo_ft_font_face_create_for_ft_face (real_face, load_flags);
	/* Keep the face SV (and thus the FT_Face) alive long enough */
	SvREFCNT_inc (face);
	status = cairo_font_face_set_user_data (RETVAL, &face_key, face,
	                                        face_destroy);
	if (status) {
		warn ("Couldn't install a user data handler, "
		      "so an FT_Face will be leaked");
	}
    OUTPUT:
	RETVAL