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