File: 210-struts.t

package info (click to toggle)
libtext-layout-perl 0.045-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 548 kB
  • sloc: perl: 4,117; makefile: 2
file content (43 lines) | stat: -rwxr-xr-x 943 bytes parent folder | download | duplicates (2)
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
#! perl

use strict;
use warnings;
use utf8;
use Test::More;
if ( eval { require PDF::API2 } ) {
    plan tests => 1;
}
else {
    plan skip_all => "PDF::API2 not installed";
}

use Text::Layout::Testing;

-d "t" && chdir("t");

# Create PDF document, with a page and text content.
my $pdf = PDF::API2->new;

my $text = "<strut label='start' width=10/>The quick brown fox<strut label='end'/>";

my $layout = Text::Layout->new($pdf);
my $fc = Text::Layout::FontConfig->new( corefonts => 1 );
$layout->set_font_description( $fc->from_string( "Times 20" ) );

$layout->set_markup($text);
my @s = $layout->get_struts;

my $exp = [ { _x     => 0,
	      width  => 10,
	      desc   => undef,
	      asc    => undef,
	      label  => 'start' },
	    { _x     =>  178.3,
	      desc   => undef,
	      asc    => undef,
	      width  => 0,
	      label  => 'end' } ];

delete $s[0]->{_strut};
delete $s[1]->{_strut};
is_deeply( \@s, $exp, "struts" );