]> git.imager.perl.org - imager.git/blob - W32/W32.pm
e25216db4904fa5063711ba4a6d7e3248ebbba88
[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.78";
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
52
53 sub utf8 {
54   return 1;
55 }
56
57 1;
58
59 __END__
60
61 =head1 NAME
62
63 Imager::Font::W32 - font support using C<GDI> on Win32
64
65 =head1 SYNOPSIS
66
67   use Imager;
68
69   my $img = Imager->new;
70   my $font = Imager::Font->new(face => "Arial", type => "w32");
71
72   $img->string(... font => $font);
73
74 =head1 DESCRIPTION
75
76 This provides font support on Win32.
77
78 =head1 CAVEATS
79
80 Unfortunately, older versions of Imager would install
81 Imager::Font::Win32 even if Win32 wasn't available, and if no font was
82 created would succeed in loading the module.  This means that an
83 existing Win32.pm could cause a probe success for Win32 fonts, so I've
84 renamed it.
85
86 =head1 AUTHOR
87
88 Tony Cook <tony@imager.perl.org>
89
90 =head1 SEE ALSO
91
92 Imager, Imager::Font.
93
94 =cut