]> git.imager.perl.org - imager.git/blob - W32/W32.pm
763df5fef2dc7973076556ad5e462071b4cf0d42
[imager.git] / W32 / W32.pm
1 package Imager::Font::W32;
2 use strict;
3 use Imager;
4 use vars qw($VERSION @ISA);
5 @ISA = qw(Imager::Font);
6
7 BEGIN {
8   $VERSION = "0.79";
9
10   eval {
11     require XSLoader;
12     XSLoader::load('Imager::Font::W32', $VERSION);
13     1;
14   } or do {
15     require DynaLoader;
16     push @ISA, 'DynaLoader';
17     bootstrap Imager::Font::W32 $VERSION;
18   };
19 }
20
21 # called by Imager::Font::new()
22 # since Win32's HFONTs include the size information this
23 # is just a stub
24 sub new {
25   my ($class, %opts) = @_;
26
27   return bless \%opts, $class;
28 }
29
30 sub _bounding_box {
31   my ($self, %opts) = @_;
32   
33   my @bbox = i_wf_bbox($self->{face}, $opts{size}, $opts{string}, $opts{utf8});
34 }
35
36 sub _draw {
37   my $self = shift;
38
39   my %input = @_;
40   if (exists $input{channel}) {
41     i_wf_cp($self->{face}, $input{image}{IMG}, $input{x}, $input{'y'},
42             $input{channel}, $input{size},
43             $input{string}, $input{align}, $input{aa}, $input{utf8});
44   }
45   else {
46     i_wf_text($self->{face}, $input{image}{IMG}, $input{x}, 
47               $input{'y'}, $input{color}, $input{size}, 
48               $input{string}, $input{align}, $input{aa}, $input{utf8});
49   }
50
51   return 1;
52 }
53
54
55 sub utf8 {
56   return 1;
57 }
58
59 1;
60
61 __END__
62
63 =head1 NAME
64
65 Imager::Font::W32 - font support using C<GDI> on Win32
66
67 =head1 SYNOPSIS
68
69   use Imager;
70
71   my $img = Imager->new;
72   my $font = Imager::Font->new(face => "Arial", type => "w32");
73
74   $img->string(... font => $font);
75
76 =head1 DESCRIPTION
77
78 This provides font support on Win32.
79
80 =head1 CAVEATS
81
82 Unfortunately, older versions of Imager would install
83 Imager::Font::Win32 even if Win32 wasn't available, and if no font was
84 created would succeed in loading the module.  This means that an
85 existing Win32.pm could cause a probe success for Win32 fonts, so I've
86 renamed it.
87
88 =head1 AUTHOR
89
90 Tony Cook <tonyc@cpan.org>
91
92 =head1 SEE ALSO
93
94 Imager, Imager::Font.
95
96 =cut