Permalink
Browse files

move win32 font support in a new directory, and use Imager::Probe

change i_utf8_advance to accept the working length as a size_t and
propagate that change through anything that uses it
  • Loading branch information...
1 parent 6725cca commit 718b8c972da5014386e04ce9663464b9f44391dc Tony Cook committed Sep 16, 2010
Showing with 456 additions and 246 deletions.
  1. +3 −0 Imager.pm
  2. +3 −89 Imager.xs
  3. +8 −3 MANIFEST
  4. +14 −14 Makefile.PL
  5. +0 −1 TIFF/TIFF.pm
  6. +117 −0 W32/Makefile.PL
  7. +94 −0 W32/W32.pm
  8. +101 −0 W32/W32.xs
  9. BIN W32/fontfiles/ExistenceTest.ttf
  10. +14 −0 W32/imw32.h
  11. +26 −0 W32/lib/Imager/Font/Win32.pm
  12. +20 −17 t/t37w32font.t → W32/t/t10win32.t
  13. +2 −1 { → W32}/win32.c
  14. +18 −18 font.c
  15. +11 −11 freetyp2.c
  16. +14 −26 imager.h
  17. +2 −1 imext.c
  18. +2 −0 imext.h
  19. +1 −0 imexttypes.h
  20. +1 −1 imio.h
  21. +1 −1 io.c
  22. +4 −0 lib/Imager/APIRef.pod
  23. +0 −63 lib/Imager/Font/Win32.pm
View
@@ -174,6 +174,7 @@ my %format_classes =
gif => "Imager::File::GIF",
tiff => "Imager::File::TIFF",
jpeg => "Imager::File::JPEG",
+ w32 => "Imager::Font::W32",
);
tie %formats, "Imager::FORMATS", \%formats_low, \%format_classes;
@@ -3906,6 +3907,8 @@ sub _check {
sub FETCH {
my ($self, $key) = @_;
+ $DB::single = 1;
+
exists $self->[IX_FORMATS]{$key} and return $self->[IX_FORMATS]{$key};
$self->[IX_CLASSES]{$key} or return undef;
View
@@ -2129,7 +2129,7 @@ i_t1_glyph_name(handle, text_sv, utf8 = 0)
PREINIT:
char const *text;
STRLEN work_len;
- int len;
+ size_t len;
char name[255];
PPCODE:
#ifdef SvUTF8
@@ -2323,7 +2323,7 @@ i_tt_glyph_name(handle, text_sv, utf8 = 0)
PREINIT:
char const *text;
STRLEN work_len;
- int len;
+ size_t len;
int outsize;
char name[255];
PPCODE:
@@ -3808,92 +3808,6 @@ i_tags_count(im)
OUTPUT:
RETVAL
-#ifdef HAVE_WIN32
-
-void
-i_wf_bbox(face, size, text_sv, utf8=0)
- char *face
- int size
- SV *text_sv
- int utf8
- PREINIT:
- int cords[BOUNDING_BOX_COUNT];
- int rc, i;
- char const *text;
- STRLEN text_len;
- PPCODE:
- text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- if (rc = i_wf_bbox(face, size, text, text_len, cords, utf8)) {
- EXTEND(SP, rc);
- for (i = 0; i < rc; ++i)
- PUSHs(sv_2mortal(newSViv(cords[i])));
- }
-
-undef_int
-i_wf_text(face, im, tx, ty, cl, size, text_sv, align, aa, utf8 = 0)
- char *face
- Imager::ImgRaw im
- int tx
- int ty
- Imager::Color cl
- int size
- SV *text_sv
- int align
- int aa
- int utf8
- PREINIT:
- char const *text;
- STRLEN text_len;
- CODE:
- text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- RETVAL = i_wf_text(face, im, tx, ty, cl, size, text, text_len,
- align, aa, utf8);
- OUTPUT:
- RETVAL
-
-undef_int
-i_wf_cp(face, im, tx, ty, channel, size, text_sv, align, aa, utf8 = 0)
- char *face
- Imager::ImgRaw im
- int tx
- int ty
- int channel
- int size
- SV *text_sv
- int align
- int aa
- int utf8
- PREINIT:
- char const *text;
- STRLEN text_len;
- CODE:
- text = SvPV(text_sv, text_len);
-#ifdef SvUTF8
- if (SvUTF8(text_sv))
- utf8 = 1;
-#endif
- RETVAL = i_wf_cp(face, im, tx, ty, channel, size, text, text_len,
- align, aa, utf8);
- OUTPUT:
- RETVAL
-
-undef_int
-i_wf_addfont(font)
- char *font
-
-undef_int
-i_wf_delfont(font)
- char *font
-
-#endif
#ifdef HAVE_FT2
@@ -4147,7 +4061,7 @@ i_ft2_glyph_name(handle, text_sv, utf8 = 0, reliable_only = 1)
PREINIT:
char const *text;
STRLEN work_len;
- int len;
+ size_t len;
char name[255];
PPCODE:
#ifdef SvUTF8
View
@@ -145,6 +145,14 @@ TIFF/testimg/srgba16.tif
TIFF/testimg/srgba32.tif
TIFF/testimg/srgbaa.tif RGB with 2 alpha
TIFF/testimg/tiffwarn.tif Generates a warning while being read
+W32/fontfiles/ExistenceTest.ttf
+W32/imw32.h
+W32/lib/Imager/Font/Win32.pm
+W32/t/t10win32.t Tests Win32 GDI font support
+W32/win32.c Implements font support through Win32 GDI
+W32/Makefile.PL
+W32/W32.pm
+W32/W32.xs
apidocs.perl Build lib/Imager/APIRef.pm
bigtest.perl Library selection tester
bmp.c Reading and writing Windows BMP files
@@ -236,7 +244,6 @@ lib/Imager/Font/FreeType2.pm
lib/Imager/Font/Image.pm
lib/Imager/Font/Truetype.pm
lib/Imager/Font/Type1.pm
-lib/Imager/Font/Win32.pm
lib/Imager/Font/Wrap.pm
lib/Imager/Fountain.pm
lib/Imager/Handy.pod
@@ -322,7 +329,6 @@ t/t21draw.t Basic drawing tests
t/t30t1font.t
t/t35ttfont.t
t/t36oofont.t
-t/t37w32font.t Tests Win32 GDI font support
t/t38ft2font.t Tests freetype2 support
t/t40scale.t
t/t50basicoo.t
@@ -424,4 +430,3 @@ tga.c Reading and writing Targa files
trans2.c
transform.perl Shell interface to Imager::Transform
typemap
-win32.c Implements font support through Win32 GDI
View
@@ -626,20 +626,20 @@ visual quality esp on low resultions. The freetype library is
used to rasterize for us. The only drawback is that there
are alot of badly designed fonts out there.}
};
- $formats{'w32'} = {
- order=>40,
- def=>'HAVE_WIN32',
- inccheck=>sub { -e catfile($_[0], 'windows.h') },
- libcheck=>sub { lc $_[0] eq 'gdi32.lib'
- || lc $_[0] eq 'libgdi32.a' },
- libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
- objfiles=>'win32.o',
- docs => <<DOCS
-Uses the Win32 GDI for rendering text.
-
-This currently only works on under normal Win32 and cygwin.
-DOCS
- };
+# $formats{'w32'} = {
+# order=>40,
+# def=>'HAVE_WIN32',
+# inccheck=>sub { -e catfile($_[0], 'windows.h') },
+# libcheck=>sub { lc $_[0] eq 'gdi32.lib'
+# || lc $_[0] eq 'libgdi32.a' },
+# libfiles=>$^O eq 'cygwin' ? '-lgdi32' : '',
+# objfiles=>'win32.o',
+# docs => <<DOCS
+# Uses the Win32 GDI for rendering text.
+
+# This currently only works on under normal Win32 and cygwin.
+# DOCS
+# };
$formats{'freetype2'} =
{
order=>'29',
View
@@ -11,7 +11,6 @@ BEGIN {
XSLoader::load('Imager::File::TIFF', $VERSION);
1;
} or do {
-print STDERR "Falling back to DynaLoader ($@)\n";
require DynaLoader;
push @ISA, 'DynaLoader';
bootstrap Imager::File::TIFF $VERSION;
View
@@ -0,0 +1,117 @@
+#!perl -w
+use strict;
+use ExtUtils::MakeMaker qw(WriteMakefile WriteEmptyMakefile);
+use Getopt::Long;
+use Config;
+
+my $verbose = $ENV{IM_VERBOSE};
+my @libpaths;
+my @incpaths;
+
+GetOptions("incpath=s", \@incpaths,
+ "libpath=s" => \@libpaths,
+ "verbose|v" => \$verbose);
+
+our $BUILDING_IMAGER;
+
+$DB::single = 1;
+
+my $MM_ver = eval $ExtUtils::MakeMaker::VERSION;
+
+my %opts =
+ (
+ NAME => 'Imager::Font::W32',
+ VERSION_FROM => 'W32.pm',
+ OBJECT => 'W32.o win32.o',
+ );
+
+my @inc;
+if ($BUILDING_IMAGER) {
+ push @inc, "-I..";
+ unshift @INC, "../lib";
+}
+else {
+ unshift @INC, "inc";
+ print "Win32: building independently\n";
+ require Imager::ExtUtils;
+ push @inc, Imager::ExtUtils->includes;
+ $opts{TYPEMAPS} = [ Imager::ExtUtils->typemap ];
+
+ # Imager required configure through use
+ my @Imager_req = ( Imager => "0.77" );
+ if ($MM_ver >= 6.46) {
+ $opts{META_MERGE} =
+ {
+ configure_requires =>
+ {
+ @Imager_req,
+ },
+ build_requires =>
+ {
+ @Imager_req,
+ "Test::More" => "0.47",
+ },
+ resources =>
+ {
+ homepage => "http://imager.perl.org/",
+ repository =>
+ {
+ url => "http://imager.perl.org/svn/trunk/Imager-Font-W32",
+ web => "http://imager.perl.org/svnweb/public/browse/trunk/Imager-Font-W32",
+ type => "svn",
+ },
+ },
+ };
+ $opts{PREREQ_PM} =
+ {
+ @Imager_req,
+ };
+ }
+}
+
+require Imager::Probe;
+
+my %probe =
+ (
+ name => "Win32",
+ inccheck => sub { -e File::Spec->catfile($_[0], "windows.h") },
+ libbase => "gdi32",
+ testcode => _win32_test_code(),
+ testcodeheaders => [ "stdio.h", "string.h", "windows.h" ],
+ incpath => join($Config{path_sep}, @incpaths),
+ libpath => join($Config{path_sep}, @libpaths),
+ );
+
+my $probe_res = Imager::Probe->probe(\%probe);
+if ($probe_res) {
+ push @inc, $probe_res->{INC};
+ $opts{LIBS} = $probe_res->{LIBS};
+
+ $opts{INC} = "@inc";
+
+ if ($MM_ver > 6.06) {
+ $opts{AUTHOR} = 'Tony Cook <tony@imager.perl.org>';
+ $opts{ABSTRACT} = 'Win32 font file support for Imager';
+ }
+
+ WriteMakefile(%opts);
+}
+else {
+ if ($BUILDING_IMAGER) {
+ WriteEmptyMakefile(%opts);
+ }
+ else {
+ # fail in good way
+ die "OS unsupported: Win32 libraries or headers not found\n";
+ }
+}
+
+sub _win32_test_code {
+ return <<'CODE';
+HDC dc = GetDC(NULL);
+HDC bmpDc = CreateCompatibleDC(dc);
+DeleteDC(bmpDc);
+ReleaseDC(NULL, dc);
+return 0;
+CODE
+}
Oops, something went wrong.

0 comments on commit 718b8c9

Please sign in to comment.