From: Tony Cook Date: Wed, 10 Mar 2004 13:22:41 +0000 (+0000) Subject: - only call FT_Get_Postscript_Name() on FT 2.0.6 and later X-Git-Tag: Imager-0.48^2~327 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/042cdaeaf24fcba235c050a5c430facf4c72c3b9 - 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(). --- diff --git a/Changes b/Changes index d837718e..547ef125 100644 --- 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(). ================================================================= diff --git a/Imager.xs b/Imager.xs index 81ff9c62..9884e684 100644 --- 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 + diff --git a/Makefile.PL b/Makefile.PL index de6bed01..642bb886 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -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}; diff --git a/freetyp2.c b/freetyp2.c index 2a4c727f..2434a875 100644 --- a/freetyp2.c +++ b/freetyp2.c @@ -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 e90d30f0..50062c4f 100644 --- 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); diff --git a/lib/Imager/Engines.pod b/lib/Imager/Engines.pod index 68aec86c..fcf931b9 100644 --- a/lib/Imager/Engines.pod +++ b/lib/Imager/Engines.pod @@ -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 + +=item hI + +The width and height of each of the input images, C is the width +of the first input image and so on. + +=item cxI + +=item cyI + +The center of each of the input images, (C, C) is the center +of the first input image and so on. + =back A few examples: diff --git a/t/t38ft2font.t b/t/t38ft2font.t index 4b36b61d..3f3e5101 100644 --- a/t/t38ft2font.t +++ b/t/t38ft2font.t @@ -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"); diff --git a/t/testtools.pl b/t/testtools.pl index ac5cbaf3..ec46d30b 100644 --- a/t/testtools.pl +++ b/t/testtools.pl @@ -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"; }