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