line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22
|
use v5.26; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
6
|
use Object::Pad; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
97
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
24
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
110
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
class SVGPDF::Tspan :isa(SVGPDF::Element); |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
method process () { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $atts = $self->atts; |
12
|
0
|
|
|
|
|
|
my $xo = $self->xo; |
13
|
0
|
0
|
|
|
|
|
return if $atts->{omit}; # for testing/debugging. |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my ( $x, $y, $dx, $dy ) = |
16
|
|
|
|
|
|
|
$self->get_params( $atts, qw( x:H y:V dx:s dy:s ) ); |
17
|
0
|
|
|
|
|
|
my $style = $self->style; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Scale dx/dy to font size, if using em units. |
20
|
0
|
|
|
|
|
|
$style->{'font-size'} = 0+$self->u($style->{'font-size'}); |
21
|
0
|
0
|
|
|
|
|
if ( $dx =~ /^([.\d]+)em$/ ) { |
22
|
0
|
|
|
|
|
|
$dx = $1 * $style->{'font-size'}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
0
|
|
0
|
|
|
|
$dx = $self->u($dx||0); |
26
|
|
|
|
|
|
|
} |
27
|
0
|
0
|
|
|
|
|
if ( $dy =~ /^([.\d]+)em$/ ) { |
28
|
0
|
|
|
|
|
|
$dy = $1 * $style->{'font-size'}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
0
|
|
0
|
|
|
|
$dy = $self->u($dy||0); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $text = ""; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $color = $style->{fill}; |
37
|
0
|
0
|
0
|
|
|
|
$color = $style->{color} if $color && $color eq "currentColor"; |
38
|
0
|
|
0
|
|
|
|
my $anchor = $style->{'text-anchor'} || "left"; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->_dbg( $self->name, " ", |
41
|
|
|
|
|
|
|
defined($atts->{x}) ? ( " x=$x" ) : (), |
42
|
|
|
|
|
|
|
defined($atts->{y}) ? ( " y=$y" ) : (), |
43
|
|
|
|
|
|
|
defined($atts->{dx}) ? ( " dx=$dx" ) : (), |
44
|
|
|
|
|
|
|
defined($atts->{dy}) ? ( " dy=$dy" ) : (), |
45
|
0
|
0
|
|
|
|
|
defined($style->{"text-anchor"}) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
|
|
|
|
|
|
? ( " anchor=\"$anchor\"" ) : (), |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my @c = $self->get_children; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
|
if ( $color ) { |
52
|
0
|
|
|
|
|
|
$xo->fill_color($color); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
|
|
|
my $x = $dx + $x; |
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $y = $dy + $y; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my %o = (); |
60
|
0
|
0
|
|
|
|
|
$o{align} = $anchor eq "end" |
|
|
0
|
|
|
|
|
|
61
|
|
|
|
|
|
|
? "right" |
62
|
|
|
|
|
|
|
: $anchor eq "middle" ? "center" : "left"; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ( 0 && $x && !$y && $o{align} eq "left" ) { |
65
|
|
|
|
|
|
|
$o{indent} = $x; |
66
|
|
|
|
|
|
|
$self->_dbg( "txt indent %.2f", $x ); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
0
|
|
|
|
|
elsif ( $x || $y ) { |
69
|
0
|
|
|
|
|
|
$self->_dbg( "txt translate( %.2f, %.2f )", $x, $y ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
for my $c ( @c ) { |
73
|
0
|
|
|
|
|
|
$self->_dbg( "+ xo save" ); |
74
|
0
|
|
|
|
|
|
$xo->save; |
75
|
0
|
|
|
|
|
|
$xo->transform( translate => [ $x, -$y ] ); |
76
|
0
|
0
|
|
|
|
|
if ( ref($c) eq 'SVGPDF::TextElement' ) { |
|
|
0
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$xo->textstart; |
78
|
0
|
|
|
|
|
|
$self->set_font( $xo, $style ); |
79
|
0
|
|
|
|
|
|
$x += $xo->text( $c->content, %o ); |
80
|
0
|
|
|
|
|
|
$xo->textend; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ( ref($c) eq 'SVGPDF::Tspan' ) { |
83
|
0
|
|
|
|
|
|
my ( $x0, $y0 ) = $c->process; |
84
|
0
|
|
|
|
|
|
$x += $x0; $y += $y0; |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->_dbg("tspan moved to $x, $y"); |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
$self->_dbg( "- xo restore" ); |
88
|
0
|
|
|
|
|
|
$xo->restore; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
$self->css_pop; |
92
|
0
|
0
|
|
|
|
|
return wantarray ? ( $x, $y ) : $x; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |