]> git.imager.perl.org - imager.git/commitdiff
report the Freetype 2 library version to STDERR in the first FT2 test
authorTony Cook <tony@develop-help.com>
Fri, 23 Nov 2012 12:15:27 +0000 (23:15 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 23 Nov 2012 12:15:27 +0000 (23:15 +1100)
this *may* allow diagnosis of some test failures

FT2/FT2.pm
FT2/FT2.xs
FT2/freetyp2.c
FT2/imft2.h
FT2/t/t10ft2.t

index a8ac99c285f8ba04fba03260fbe9b129bfac8b12..1178700055c8c43f9a082ce05d1ddc984baf229e 100644 (file)
@@ -5,7 +5,7 @@ use vars qw($VERSION @ISA);
 @ISA = qw(Imager::Font);
 
 BEGIN {
-  $VERSION = "0.86";
+  $VERSION = "0.87";
 
   require XSLoader;
   XSLoader::load('Imager::Font::FT2', $VERSION);
index ac8396efbd7779de4fd19e0cd90323435efc184b..95bf49518a3d1e00a7ab337ca4f458562c77eb7c 100644 (file)
@@ -34,6 +34,19 @@ i_ft2_new(name, index)
         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
index fc060efdb1c521a091f1017210af146868338325..e7bd8508131bb34e3db1ec45eef635d31b43a692 100644 (file)
@@ -38,6 +38,7 @@ Truetype, Type1 and Windows FNT.
 #include "imft2.h"
 #include <stdio.h>
 #include <math.h>
+#include <string.h>
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #ifdef FT_MULTIPLE_MASTERS_H
@@ -55,6 +56,36 @@ static FT_Library library;
 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)
 
index 57b71293732e2e9fa9889ac6a605e9983dd254bd..842af88dbe5ec8802e006adc9b4ec6a8896afb15 100644 (file)
@@ -8,6 +8,7 @@ typedef struct FT2_Fonthandle FT2_Fonthandle;
 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);
index 785fdf873246cd8ceb8e97daab74578dc6e0d9fd..ad1c6e80df2eec616c39ee1b23e429673aa53d3c 100644 (file)
@@ -23,6 +23,8 @@ SKIP:
 
   -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);