char *name
int index
+const char *
+i_ft2_version(runtime)
+ int runtime
+ PREINIT:
+ char buf[100];
+ CODE:
+ if (!i_ft2_version(runtime, buf, sizeof(buf))) {
+ XSRETURN_EMPTY;
+ }
+ RETVAL = buf;
+ OUTPUT:
+ RETVAL
+
undef_int
i_ft2_setdpi(font, xdpi, ydpi)
Imager::Font::FT2x font
#include "imft2.h"
#include <stdio.h>
#include <math.h>
+#include <string.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef FT_MULTIPLE_MASTERS_H
static i_img_dim i_min(i_img_dim a, i_img_dim b);
static i_img_dim i_max(i_img_dim a, i_img_dim b);
+int
+i_ft2_version(int runtime, char *buf, size_t buf_size) {
+ char work[100];
+ i_clear_error();
+
+ if (!ft2_initialized && !i_ft2_init())
+ return NULL;
+
+ if (buf_size == 0) {
+ i_push_error(0, "zero size buffer supplied");
+ return 0;
+ }
+ if (runtime) {
+ /* initialized to work around a bug in FT2
+ http://lists.nongnu.org/archive/html/freetype-devel/2002-09/msg00058.html
+ Though I don't know why I still see this in 2.4.2
+ */
+ FT_Int major = 1, minor = 1, patch = 1;
+ FT_Library_Version(library, &major, &minor, &patch);
+ sprintf(work, "%d.%d.%d", (int)major, (int)minor, (int)patch);
+ }
+ else {
+ sprintf(work, "%d.%d.%d", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH);
+ }
+ strncpy(buf, work, buf_size);
+ buf[buf_size-1] = '\0';
+
+ return 1;
+}
+
/*
=item i_ft2_init(void)
typedef FT2_Fonthandle* Imager__Font__FT2x;
extern int i_ft2_init(void);
+extern int i_ft2_version(int runtime, char *buf, size_t buf_size);
extern FT2_Fonthandle * i_ft2_new(const char *name, int index);
extern void i_ft2_destroy(FT2_Fonthandle *handle);
extern int i_ft2_setdpi(FT2_Fonthandle *handle, int xdpi, int ydpi);
-f $fontname or skip("cannot find fontfile $fontname", 189);
+ print STDERR "FreeType2 runtime ", Imager::Font::FT2::i_ft2_version(1),
+ " compile-time ", Imager::Font::FT2::i_ft2_version(0), "\n";
my $bgcolor=i_color_new(255,0,0,0);
my $overlay=Imager::ImgRaw::new(200,70,3);