]> git.imager.perl.org - imager.git/commitdiff
- only call FT_Get_Postscript_Name() on FT 2.0.6 and later
authorTony Cook <tony@develop=help.com>
Wed, 10 Mar 2004 13:22:41 +0000 (13:22 +0000)
committerTony Cook <tony@develop=help.com>
Wed, 10 Mar 2004 13:22:41 +0000 (13:22 +0000)
- put the IM_LIBPATH and IM_INCPATH values first in the search
  path so the builder gets their local versions if desired rather
  than the system versions they might be trying to avoid
- document the exp() and log() transform2() functions
- document the constants normally set by transform2().

Changes
Imager.xs
Makefile.PL
freetyp2.c
image.h
lib/Imager/Engines.pod
t/t38ft2font.t
t/testtools.pl

diff --git a/Changes b/Changes
index d837718e1ce066059b117cdbbdd784f66b227941..547ef125343a0a3a9c59e77efd58b4d6d77432f0 100644 (file)
--- a/Changes
+++ b/Changes
@@ -733,12 +733,18 @@ Revision history for Perl extension Imager.
          them to imager.perl.org ones.
 
 0.43
-        - added log() and exp() functions to transform2()
+       - added log() and exp() functions to transform2()
        - change the getpN() functions in transform2() to set a 
          reasonable alpha if the input image has no alpha
        - document the constants that transform2() defines
        - skip the right number of tests when FT2 isn't available
        - This version pushed to CPAN because of skip problem in FT2 test.
+       - only call FT_Get_Postscript_Name() on FT 2.0.6 and later
+       - put the IM_LIBPATH and IM_INCPATH values first in the search
+         path so the builder gets their local versions if desired rather
+         than the system versions they might be trying to avoid
+       - document the exp() and log() transform2() functions
+       - document the constants normally set by transform2().
 
 =================================================================
 
index 81ff9c62fa6ae515563cc8641a00813df6ba72f0..9884e6849d077a132e27b39ef07f646d3dbf26d0 100644 (file)
--- a/Imager.xs
+++ b/Imager.xs
@@ -4226,6 +4226,9 @@ i_ft2_face_name(handle)
           PUSHs(sv_2mortal(newSVpv(name, 0)));
         }
 
+undef_int
+i_ft2_can_face_name()
+
 void
 i_ft2_glyph_name(handle, text_sv, utf8 = 0)
         Imager::Font::FT2 handle
@@ -4370,3 +4373,4 @@ i_new_fill_image(src, matrix, xoff, yoff, combine)
         RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
       OUTPUT:
         RETVAL
+
index de6bed012ae127ddded33da357ccf7372ca0d63f..642bb88696b1d121d325431af771b1aeb6fbba43 100644 (file)
@@ -263,8 +263,12 @@ sub pathcheck {
 sub init {
 
   @definc{'/usr/include'}=();
-  @incs=(qw(/sw/include /usr/include/freetype2 /usr/local/include/freetype2 /usr/include /usr/local/include /usr/include/freetype /usr/local/include/freetype), split /\Q$Config{path_sep}/, $INCPATH );
-  @libs=(qw(/sw/lib), split(/\Q$Config{path_sep}/,$LIBPATH) , split(/ /, $Config{'libpth'}));
+  @incs=(split(/\Q$Config{path_sep}/, $INCPATH), 
+         qw(/sw/include /usr/include/freetype2 /usr/local/include/freetype2 
+            /usr/include /usr/local/include /usr/include/freetype 
+            /usr/local/include/freetype));
+  @libs=(split(/\Q$Config{path_sep}/,$LIBPATH), 
+         qw(/sw/lib),  split(/ /, $Config{'libpth'}));
   if ($^O =~ /win32/i && $Config{cc} =~ /\bcl\b/i) {
     push(@incs, split /;/, $ENV{INCLUDE}) if exists $ENV{INCLUDE};
     push(@libs, split /;/, $ENV{LIB}) if exists $ENV{LIB};
index 2a4c727ffeae04fbde716c07c2da4f83a6103024..2434a875ef6af5fd0375faab7ffc40bf218ca30f 100644 (file)
@@ -884,8 +884,28 @@ make_bmp_map(FT_Bitmap *bitmap, unsigned char *map) {
   return 1;
 }
 
+/* FREETYPE_PATCH was introduced in 2.0.6, we don't want a false 
+   positive on 2.0.0 to 2.0.4, so we accept a false negative in 2.0.5 */
+#ifndef FREETYPE_PATCH
+#define FREETYPE_PATCH 4
+#endif
+
+/* FT_Get_Postscript_Name() was introduced in FT2.0.5 */
+#define IM_HAS_FACE_NAME (FREETYPE_MINOR > 0 || FREETYPE_PATCH >= 5)
+/* #define IM_HAS_FACE_NAME 0 */ 
+
+/*
+=item i_ft2_face_name(handle, name_buf, name_buf_size)
+
+Fills the given buffer with the Postscript Face name of the font,
+if there is one.
+
+=cut
+*/
+
 int
 i_ft2_face_name(FT2_Fonthandle *handle, char *name_buf, size_t name_buf_size) {
+#if IM_HAS_FACE_NAME
   char const *name = FT_Get_Postscript_Name(handle->face);
 
   i_clear_error();
@@ -902,6 +922,18 @@ i_ft2_face_name(FT2_Fonthandle *handle, char *name_buf, size_t name_buf_size) {
 
     return 0;
   }
+#else
+  i_clear_error();
+  i_push_error(0, "Freetype 2.0.6 or later required");
+  *name_buf = '\0';
+
+  return 0;
+#endif
+}
+
+int
+i_ft2_can_face_name(void) {
+  return IM_HAS_FACE_NAME;
 }
 
 /* FT_Has_PS_Glyph_Names() was introduced in FT2.1.1 */
diff --git a/image.h b/image.h
index e90d30f07bfacb2975d1c0b0340792f44ab34696..50062c4f53746cc0a6c45457ecbd83923cac07e0 100644 (file)
--- a/image.h
+++ b/image.h
@@ -305,6 +305,7 @@ extern int i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, int len,
                            int utf8, char *work);
 extern int i_ft2_face_name(FT2_Fonthandle *handle, char *name_buf, 
                            size_t name_buf_size);
+extern int i_ft2_can_face_name(void);
 extern int i_ft2_glyph_name(FT2_Fonthandle *handle, unsigned char ch, 
                             char *name_buf, size_t name_buf_size);
 extern int i_ft2_can_do_glyph_names(void);
index 68aec86c9aac94cec5a268944a2a44946f4ab1bd..fcf931b9269c709470bff8e3c61935f362f5b975 100644 (file)
@@ -220,6 +220,48 @@ epsilon value is used.
 
 Basic logical operators.
 
+=item log(n), exp(n)
+
+Natural logarithm and exponential.
+
+=back
+
+=item Constants
+
+transform2() defines the following constants:
+
+=over
+
+=item pi
+
+The classical constant.
+
+=item w
+
+=item h
+
+The width and height of the output image.
+
+=item cx
+
+=item cy
+
+The center of the output image.
+
+=item wI<image number>
+
+=item hI<image number>
+
+The width and height of each of the input images, C<w1> is the width
+of the first input image and so on.
+
+=item cxI<image number>
+
+=item cyI<image number>
+
+The center of each of the input images, (C<cx1>, C<cy1>) is the center
+of the first input image and so on.
+
 =back
 
 A few examples:
index 4b36b61db1a043acfefc4f61bf50318b04b815fc..3f3e5101d926031c28214fc9dd2d3e9ff953660d 100644 (file)
@@ -242,12 +242,22 @@ if (okx($exfont, "loaded existence font")) {
   okx($bbox->pos_width != $bbox->advance_width, "OO check");
 
   # name tests
-  my $facename = Imager::Font::FreeType2::i_ft2_face_name($exfont->{id});
-  print "# face name '$facename'\n";
-  okx($facename eq 'ExistenceTest', "test face name");
-  $facename = $exfont->face_name;
-  okx($facename eq 'ExistenceTest', "test face name OO");
-
+  # make sure the number of tests on each branch match
+  if (Imager::Font::FreeType2::i_ft2_can_face_name()) {
+    my $facename = Imager::Font::FreeType2::i_ft2_face_name($exfont->{id});
+    print "# face name '$facename'\n";
+    okx($facename eq 'ExistenceTest', "test face name");
+    $facename = $exfont->face_name;
+    okx($facename eq 'ExistenceTest', "test face name OO");
+  }
+  else {
+    # make sure we get the error we expect
+    my $facename = Imager::Font::FreeType2::i_ft2_face_name($exfont->{id});
+    my ($msg) = Imager::_error_as_msg();
+    okx(!defined($facename), "test face name not supported");
+    print "# $msg\n";
+    okx(scalar($msg =~ /or later required/), "test face name not supported");
+  }
 }
 else {
   skipx(5, "couldn't load test font");
index ac5cbaf3d5073f7feebdf87224e20a81a8143ff5..ec46d30bd75bd334bdffb13edfd49fe06e68ba07 100644 (file)
@@ -1,6 +1,7 @@
 # this doesn't need a new namespace - I hope
 use Imager qw(:all);
 use vars qw($TESTNUM);
+use Carp 'confess';
 
 $TESTNUM = 1;
 
@@ -43,6 +44,8 @@ sub okx {
 sub okn {
   my ($num, $ok, $comment) = @_;
 
+  defined $num or confess "No \$num supplied";
+  defined $comment or confess "No \$comment supplied";
   if ($ok) {
     print "ok $num # $comment\n";
   }