]> git.imager.perl.org - imager.git/blame - lib/Imager/Font/Truetype.pm
Removed unused variable, commented out unused function.
[imager.git] / lib / Imager / Font / Truetype.pm
CommitLineData
96190b6e
TC
1package Imager::Font::Truetype;
2use strict;
3use vars qw(@ISA);
4@ISA = qw(Imager::Font);
5
6sub new {
7 my $class = shift;
8 my %hsh=(color=>Imager::Color->new(255,0,0,0),
9 size=>15,
10 @_);
11
12 unless ($hsh{file}) {
13 $Imager::ERRSTR = "No font file specified";
14 return;
15 }
16 unless (-e $hsh{file}) {
17 $Imager::ERRSTR = "Font file $hsh{file} not found";
18 return;
19 }
20 unless ($Imager::formats{tt}) {
21 $Imager::ERRSTR = "Type 1 fonts not supported in this build";
22 return;
23 }
24 my $id = Imager::i_tt_new($hsh{file});
25 unless ($id >= 0) { # the low-level code may miss some error handling
26 $Imager::ERRSTR = "Could not load font ($id)";
27 return;
28 }
29 return bless {
30 id => $id,
31 aa => $hsh{aa} || 0,
32 file => $hsh{file},
33 type => 'tt',
34 size => $hsh{size},
35 color => $hsh{color},
36 }, $class;
37}
38
39sub _draw {
40 my $self = shift;
41 my %input = @_;
42 if ( exists $input{channel} ) {
43 Imager::i_tt_cp($self->{id},$input{image}{IMG},
44 $input{x}, $input{'y'}, $input{channel}, $input{size},
45 $input{string}, length($input{string}),$input{aa});
46 } else {
47 Imager::i_tt_text($self->{id}, $input{image}{IMG},
48 $input{x}, $input{'y'}, $input{color},
49 $input{size}, $input{string},
50 length($input{string}), $input{aa});
51 }
52}
53
54sub _bounding_box {
55 my $self = shift;
56 my %input = @_;
57 return Imager::i_tt_bbox($self->{id}, $input{size},
58 $input{string}, length($input{string}));
59}
60
611;
62
63__END__
64
65=head1 NAME
66
67 Imager::Font::Truetype - low-level functions for Truetype fonts
68
69=head1 DESCRIPTION
70
71Imager::Font creates a Imager::Font::Truetype object when asked to create
72a font object based on a .ttf file.
73
74See Imager::Font to see how to use this type.
75
76This class provides low-level functions that require the caller to
77perform data validation.
78
79=head1 AUTHOR
80
81Addi, Tony
82
83=cut