eliminate use vars
[imager.git] / lib / Imager / Font / Test.pm
CommitLineData
1136f089 1package Imager::Font::Test;
ee64a81f 2use 5.006;
1136f089
TC
3use strict;
4
ee64a81f 5our $VERSION = "1.002";
564d876b 6
1136f089
TC
7use base 'Imager::Font';
8
9sub new {
10 my ($class, %opts) = @_;
11
12 bless \%opts, shift;
13}
14
15sub _draw {
16 my ($self, %input) = @_;
17
18 my $text = $input{string};
19
20 my $ppn = int($input{size} * 0.5 + 0.5);
21 my $desc = int($input{size} * 0.3 + 0.5);
22 my $asc = $input{size} - $desc;
23 my $width = $ppn * length $text;
24 my $x = $input{x};
25 my $y = $input{'y'};
26 $input{align} and $y -= $asc;
27
28 $input{image}->box(color => $input{color}, xmin => $x, ymin => $y,
29 xmax => $x + $width-1, ymax => $y + $input{size} - 1);
30
31 return 1;
32}
33
34sub _bounding_box {
35 my ($self, %input) = @_;
36
37 my $text = $input{string};
38
39 my $ppn = int($input{size} * 0.5 + 0.5);
40 my $desc = int($input{size} * 0.3 + 0.5);
41 my $asc = $input{size} - $desc;
42
43 return ( 0, -$desc, $ppn * length $text, $asc, -$desc, $asc, $ppn * length $text, 0 );
44}
45
46sub has_chars {
47 my ($self, %input) = @_;
48
49 my $text = $input{string};
50 defined $text
51 or return Imager->_set_error("has_chars: No string parameter supplied");
52
53 return (1) x length $text;
54}
55
56sub face_name {
57 "test";
58}
59
60sub glyph_names {
61 my ($self, %input) = @_;
62
63 my $text = $input{string};
64 defined $text
65 or return Imager->_set_error("glyph_names: No string parameter supplied");
66
67 return (1) x length $text;
68}
69
701;
71
564d876b 72=head1 NAME
1136f089
TC
73
74Imager::Font::Test - font driver producing consistent output for tests.
75
76=head1 SYNOPSIS
77
78 my $font = Imager::Font::Test->new;
79
80 # use $font where you use other fonts
81
82=head1 DESCRIPTION
83
84Imager::Font::Test is intended to produce consistent output without
85being subject to the inconsistent output produced by different
86versions of font libraries.
87
88The output is simple box for the whole string.
89
90=head1 AUTHOR
91
92Tony Cook <tonyc@cpan.org>
93
94=cut
95