File Coverage

blib/lib/Imager/Font/Test.pm
Criterion Covered Total %
statement 10 36 27.7
branch 0 6 0.0
condition n/a
subroutine 4 9 44.4
pod 4 4 100.0
total 18 55 32.7


line stmt bran cond sub pod time code
1             package Imager::Font::Test;
2 1     1   52902 use 5.006;
  1         3  
3 1     1   6 use strict;
  1         1  
  1         39  
4              
5             our $VERSION = "1.002";
6              
7 1     1   4 use base 'Imager::Font';
  1         2  
  1         481  
8              
9             sub new {
10 1     1 1 511 my ($class, %opts) = @_;
11              
12 1         4 bless \%opts, shift;
13             }
14              
15             sub _draw {
16 0     0     my ($self, %input) = @_;
17              
18 0           my $text = $input{string};
19              
20 0           my $ppn = int($input{size} * 0.5 + 0.5);
21 0           my $desc = int($input{size} * 0.3 + 0.5);
22 0           my $asc = $input{size} - $desc;
23 0           my $width = $ppn * length $text;
24 0           my $x = $input{x};
25 0           my $y = $input{'y'};
26 0 0         $input{align} and $y -= $asc;
27              
28             $input{image}->box(color => $input{color}, xmin => $x, ymin => $y,
29 0           xmax => $x + $width-1, ymax => $y + $input{size} - 1);
30              
31 0           return 1;
32             }
33              
34             sub _bounding_box {
35 0     0     my ($self, %input) = @_;
36              
37 0           my $text = $input{string};
38              
39 0           my $ppn = int($input{size} * 0.5 + 0.5);
40 0           my $desc = int($input{size} * 0.3 + 0.5);
41 0           my $asc = $input{size} - $desc;
42              
43 0           return ( 0, -$desc, $ppn * length $text, $asc, -$desc, $asc, $ppn * length $text, 0 );
44             }
45              
46             sub has_chars {
47 0     0 1   my ($self, %input) = @_;
48              
49 0           my $text = $input{string};
50 0 0         defined $text
51             or return Imager->_set_error("has_chars: No string parameter supplied");
52              
53 0           return (1) x length $text;
54             }
55              
56             sub face_name {
57 0     0 1   "test";
58             }
59              
60             sub glyph_names {
61 0     0 1   my ($self, %input) = @_;
62              
63 0           my $text = $input{string};
64 0 0         defined $text
65             or return Imager->_set_error("glyph_names: No string parameter supplied");
66              
67 0           return (1) x length $text;
68             }
69              
70             1;
71              
72             =head1 NAME
73              
74             Imager::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              
84             Imager::Font::Test is intended to produce consistent output without
85             being subject to the inconsistent output produced by different
86             versions of font libraries.
87              
88             The output is simple box for the whole string.
89              
90             =head1 AUTHOR
91              
92             Tony Cook
93              
94             =cut
95