File: 010-font.t

package info (click to toggle)
libimager-perl 1.005%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,308 kB
  • ctags: 4,067
  • sloc: perl: 30,915; ansic: 27,680; makefile: 55; cpp: 4
file content (59 lines) | stat: -rw-r--r-- 1,743 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!perl -w
use strict;
use Imager;
use Test::More tests => 14;

unshift @INC, "t";

ok(Imager::Font->register(type => "test",
			  class=>"GoodTestFont",
			  files => "\\.ppm\$"),
   "register a test font");

ok(Imager::Font->register(type => "bad",
			  class => "BadTestFont",
			  files => "\\.ppm\$"),
   "register a bad test font");

ok(!Imager::Font->register(), "no register parameters");
like(Imager->errstr, qr/No type parameter/, "check message");

ok(!Imager::Font->register(type => "bad1"), "no class parameter");
like(Imager->errstr, qr/No class parameter/, "check message");

ok(!Imager::Font->register(type => "bad2", class => "BadFont", files => "**"),
   "bad files parameter");
is(Imager->errstr, "files isn't a valid regexp", "check message");

Imager::Font->priorities("bad", "test");

# RT #62855
# previously we'd select the first file matched font driver, even if
# it wasn't available, then crash loading it.

SKIP:
{
  my $good;
  ok(eval {
    $good = Imager::Font->new(file => "testimg/penguin-base.ppm");
  }, "load good font avoiding RT 62855")
    or skip("Failed to load", 1);
  ok($good->isa("GoodTestFont"), "and it's the right type");
}


use Imager::Font::Test;

# check string() and align_string() handle an empty image
{
  my $font = Imager::Font::Test->new;
  my $empty = Imager->new;
  ok(!$empty->string(text => "foo", x => 0, y => 10, size => 10, font => $font),
     "can't draw text on an empty image");
  is($empty->errstr, "string: empty input image",
     "check error message");
  ok(!$empty->align_string(text => "foo", x => 0, y => 10, size => 10, font => $font),
     "can't draw text on an empty image");
  is($empty->errstr, "align_string: empty input image",
     "check error message");
}