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().
=================================================================
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
RETVAL = i_new_fill_image(src, matrixp, xoff, yoff, combine);
OUTPUT:
RETVAL
+
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};
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();
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 */
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);
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:
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");
# this doesn't need a new namespace - I hope
use Imager qw(:all);
use vars qw($TESTNUM);
+use Carp 'confess';
$TESTNUM = 1;
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";
}