| 1 | #! perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package Text::Layout::PDFAPI2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use parent 'Text::Layout'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use List::Util qw(max); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | my $hb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | my $fc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #### API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | my ( $pkg, @data ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | unless ( @data == 1 && ref($data[0]) =~ /^PDF::(API2|Builder)\b/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@data == 1 and ref($data[0]) =~ /^PDF::(API2|Builder)\b/
MC/DC0%0/2
@data == 1 and ref($data[0]) =~ /^PDF::(API2|Builder)\b/
@data == 1
ref($data[0]) =~ /^PDF::(API2|Builder)\b/
Truth table33%1/3
A and B
A= @data == 1B= ref($data[0]) =~ /^PDF::(API2|Builder)\b/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | croak("Usage: Text::Layout::PDFAPI2->new(\$pdf)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | my $self = $pkg->SUPER::new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | $self->{_context} = $data[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | if ( !$fc || $fc->{__PDF__} ne $data[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $fc or $fc->{"__PDF__"} ne $data[0]
MC/DC0%0/2
not $fc or $fc->{"__PDF__"} ne $data[0]
not $fc
$fc->{"__PDF__"} ne $data[0]
Truth table33%1/3
not(A) or B
A= not $fcB= $fc->{"__PDF__"} ne $data[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # Init cache. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | $fc = { __PDF__ => $data[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | Text::Layout::FontConfig->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | require Text::Layout::PDFAPI2::ImageElement; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | $self->register_element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ( Text::Layout::PDFAPI2::ImageElement->new( pdf => $data[0] ), "img" ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | unless $self->get_element_handler("img"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub _pdf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pdf: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{_context}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Creates a (singleton) HarfBuzz::Shaper object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub _hb_init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hb_init: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return $hb if defined $hb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $hb = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | require HarfBuzz::Shaper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $hb = HarfBuzz::Shaper->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $hb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # Verify if a font needs shaping, and we can do that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | ▶ | sub _hb_font_check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hb_font_check: called CC=5 SCAR=23.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | my ( $f ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | return $f->{_hb_checked} if defined $f->{_hb_checked}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | if ( $f->get_shaping ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $fn = $f->to_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( $f->{font}->can("fontfilename") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( _hb_init() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # warn("Font $fn will use shaping.\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return $f->{_hb_checked} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | carp("Font $fn: Requires shaping but HarfBuzz cannot be loaded."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | carp("Font $fn: Shaping not supported"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # warn("Font ", $f->to_string, " does not need shaping.\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | return $f->{_hb_checked} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | #### API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub render { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render: called CC=59 SCAR=74.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my ( $self, $x, $y, $text, $fp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $self->{_lastx} = $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | $self->{_lasty} = $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my @bb = $self->get_pixel_bbox; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my $bl = $bb[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | my $align = $self->{_alignment} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_alignment"} // 0
MC/DC0%0/1
$self->{"_alignment"} // 0
$self->{"_alignment"}
Truth table50%1/2
A
A= $self->{"_alignment"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | if ( $self->{_width} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $w = $bb[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( $w < $self->{_width} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ( $align eq "right" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $x += $self->{_width} - $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | elsif ( $align eq "center" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $x += ( $self->{_width} - $w ) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $x += $bb[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my $upem = 1000; # as per PDF::API2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my $draw_bg = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my ( $fx, $nfx, $x, $y, $w ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $h = $bb[2]; # "border" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $d = abs($h)/25; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # If first with background, extend a little to the left. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( $fx == 0 || !$self->{_content}->[$fx-1]->{bgcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$fx == 0 or not $self->{"_content"}[$fx - 1]{"bgcolor"}
MC/DC0%0/2
$fx == 0 or not $self->{"_content"}[$fx - 1]{"bgcolor"}
$fx == 0
not $self->{"_content"}[$fx - 1]{"bgcolor"}
Truth table0%0/3
A or not(B)
A= $fx == 0B= not $self->{"_content"}[$fx - 1]{"bgcolor"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $x -= $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $w += $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # If last with background, extend a little to the right. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( $fx == $nfx-1 || !$self->{_content}->[$fx+1]->{bgcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$fx == $nfx - 1 or not $self->{"_content"}[$fx + 1]{"bgcolor"}
MC/DC0%0/2
$fx == $nfx - 1 or not $self->{"_content"}[$fx + 1]{"bgcolor"}
$fx == $nfx - 1
not $self->{"_content"}[$fx + 1]{"bgcolor"}
Truth table0%0/3
A or not(B)
A= $fx == $nfx - 1B= not $self->{"_content"}[$fx + 1]{"bgcolor"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $w += 2*$d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # If next is a strut, followed by same bg color, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # have the background span the strut. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | #### TODO: Span multiple struts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | for ( my $i = $fx+1; $i < $nfx; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ( $self->{_content}->[$i]->{type} eq "strut" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $delta //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$delta //= 0
MC/DC0%0/1
$delta //= 0
$delta
Truth table0%0/2
A
A= $delta
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $delta += $self->{_content}->[$i]->{width}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ▶ | elsif ( defined($delta) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $delta and $self->{"_content"}[$i]{"bgcolor"} and $self->{"_content"}[$i]{"bgcolor"} eq $self->{"_content"}[$fx]{"bgcolor"}
defined $delta and $self->{"_content"}[$i]{"bgcolor"}
MC/DC0%0/3
defined $delta and $self->{"_content"}[$i]{"bgcolor"} and $self->{"_content"}[$i]{"bgcolor"} eq $self->{"_content"}[$fx]{"bgcolor"}
defined $delta
$self->{"_content"}[$i]{"bgcolor"}
$self->{"_content"}[$i]{"bgcolor"} eq $self->{"_content"}[$fx]{"bgcolor"}
Truth table0%0/4
A and B and C
A= defined $deltaB= $self->{"_content"}[$i]{"bgcolor"}C= $self->{"_content"}[$i]{"bgcolor"} eq $self->{"_content"}[$fx]{"bgcolor"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | && $self->{_content}->[$i]->{bgcolor} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | && $self->{_content}->[$i]->{bgcolor} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | eq $self->{_content}->[$fx]->{bgcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $w += $delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # Draw the background. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $text->textend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $gfx = $text; # sanity | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $gfx->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $gfx->fillcolor( $self->{_content}->[$fx]->{bgcolor} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $gfx->linewidth(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $gfx->rectangle( $x, $y+$d, $x+$w, $y+$h-$d ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $text->fill; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $gfx->restore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $text->textstart; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my $nfx = @{ $self->{_content} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | for ( my $fx = 0; $fx < $nfx; $fx++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | my $fragment = $self->{_content}->[$fx]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | if ( $fragment->{type} eq "strut" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $x += $fragment->{width}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( length($fragment->{label}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $pdf = $text->{' api'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $page = $text->{' apipage'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my $target = $fragment->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Augmented API for apps that keep track of bookmarks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $c = $pdf->can("named_dest_fiddle"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $target = $pdf->$c($target) if $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $c = $pdf->can("named_dest_register"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $pdf->$c( $target, $page ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $c = ref($pdf) . '::NamedDestination'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $dest = $c->new($pdf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $dest->goto( $page, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | xyz => ( $x - $fragment->{width}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | $y + $self->{_currentsize}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | undef ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $pdf->named_destination( 'Dests', $target, $dest ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | elsif ( my $hd = $self->get_element_handler($fragment->{type}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $text->textend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $ab = $hd->render($fragment, $text, $x, $y-$bl)->{abox}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $text->textstart; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $x += $ab->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | next unless $fragment->{type} eq "text" && length($fragment->{text}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fragment->{"type"} eq "text" and length $fragment->{"text"}
MC/DC0%0/2
$fragment->{"type"} eq "text" and length $fragment->{"text"}
$fragment->{"type"} eq "text"
length $fragment->{"text"}
Truth table33%1/3
A and B
A= $fragment->{"type"} eq "text"B= length $fragment->{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | my $x0 = $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my $y0 = $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | my $f = $fragment->{font}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | my $font = $f->get_font($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | unless ( $font ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | carp("Can't happen?"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $f = $self->{_currentfont}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $font = $f->getfont($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | $text->strokecolor( $fragment->{color} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | $text->fillcolor( $fragment->{color} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | $text->font( $font, $fragment->{size} || $self->{_currentsize} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table33%1/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | if ( _hb_font_check($f) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $hb->set_font( $font->fontfilename ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $hb->set_size( $fragment->{size} || $self->{_currentsize} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table0%0/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $hb->set_text( $fragment->{text} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | $hb->set_direction( $f->{direction} ) if $f->{direction}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | $hb->set_language( $f->{language} ) if $f->{language}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $info = $hb->shaper($fp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $y = $y - $fragment->{base} - $bl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $sz = $fragment->{size} || $self->{_currentsize}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table0%0/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $w = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $w += $_->{ax} for @$info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ( $fragment->{bgcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $draw_bg->( $fx, $nfx, $x0, $y0, $w ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | foreach my $g ( @$info ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $text->translate( $x + $g->{dx}, $y - $g->{dy} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $text->glyph_by_CId( $g->{g} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $x += $g->{ax}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $y += $g->{ay}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | printf("%.2f %.2f %.2f \"%s\" %s\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | $x, $y-$fragment->{base}-$bl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | $font->width($fragment->{text}) * ($fragment->{size} || $self->{_currentsize}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $fragment->{text}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | join(" ", $fragment->{font}->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | $fragment->{font}->{style}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | $fragment->{font}->{weight}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $fragment->{size} || $self->{_currentsize}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | $fragment->{color}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | $fragment->{underline}||'""', $fragment->{underline_color}||'""', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | $fragment->{strikethrough}||'""', $fragment->{strikethrough_color}||'""', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ) if 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | my $t = $fragment->{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | ▶ | if ( $t ne "" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # See ChordPro issue 240. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | ▶ | if ( $font->issymbol && $font->is_standard ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$font->issymbol and $font->is_standard
MC/DC0%0/2
$font->issymbol and $font->is_standard
$font->issymbol
$font->is_standard
Truth table33%1/3
A and B
A= $font->issymbolB= $font->is_standard
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # This enables byte access to these symbol fonts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | utf8::downgrade( $t, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | my $y = $y-$fragment->{base}-$bl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | my $sz = $fragment->{size} || $self->{_currentsize}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table33%1/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | my $w = $font->width($t) * $sz; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | if ( $fragment->{bgcolor} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $draw_bg->( $fx, $nfx, $x0, $y0, $w ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | $text->font( $f->get_font, $sz ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | $text->translate( $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | $text->text($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | $x += $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | next unless $x > $x0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # While PDF::API2 delivers font metrics in 1/1000s, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # underlinethickness and position are unscaled UPEM. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | my $dw = $font->data->{upem} // 1000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$font->data->{"upem"} // 1000
MC/DC0%0/1
$font->data->{"upem"} // 1000
$font->data->{"upem"}
Truth table50%1/2
A
A= $font->data->{"upem"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | my @strikes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | if ( $fragment->{underline} && $fragment->{underline} ne 'none' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fragment->{"underline"} and $fragment->{"underline"} ne "none"
MC/DC0%0/2
$fragment->{"underline"} and $fragment->{"underline"} ne "none"
$fragment->{"underline"}
$fragment->{"underline"} ne "none"
Truth table33%1/3
A and B
A= $fragment->{"underline"}B= $fragment->{"underline"} ne "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $sz = $fragment->{size} || $self->{_currentsize}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table0%0/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | my $d = -( $f->{underline_position} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | || $font->underlineposition ) * $sz/$dw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$f->{'underline_position'} || $font->underlineposition
MC/DC0%0/2
$f->{'underline_position'} || $font->underlineposition
$f->{'underline_position'}
$font->underlineposition
Truth table0%0/3
A || B
A= $f->{'underline_position'}B= $font->underlineposition
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | my $h = ( $f->{underline_thickness} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | || $font->underlinethickness ) * $sz/$dw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$f->{'underline_thickness'} || $font->underlinethickness
MC/DC0%0/2
$f->{'underline_thickness'} || $font->underlinethickness
$f->{'underline_thickness'}
$font->underlinethickness
Truth table0%0/3
A || B
A= $f->{'underline_thickness'}B= $font->underlinethickness
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $col = $fragment->{underline_color} // $fragment->{color}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{"underline_color"} // $fragment->{"color"}
MC/DC0%0/2
$fragment->{"underline_color"} // $fragment->{"color"}
$fragment->{"underline_color"}
$fragment->{"color"}
Truth table0%0/3
A // B
A= $fragment->{"underline_color"}B= $fragment->{"color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ( $fragment->{underline} eq 'double' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | push( @strikes, [ $d-0.125*$h, $h * 0.75, $col ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | [ $d+1.125*$h, $h * 0.75, $col ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | push( @strikes, [ $d+$h/2, $h, $col ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | if ( $fragment->{strikethrough} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | my $sz = $fragment->{size} || $self->{_currentsize}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table0%0/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $xh = $font->xheight / 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | my $d = -( $f->{strikeline_position} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | ? $f->{strikeline_position} / $dw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | : 0.6*$xh ) * $sz; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | my $h = ( $f->{strikeline_thickness} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | || $f->{underline_thickness} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | || $font->underlinethickness ) * $sz/$dw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$f->{'strikeline_thickness'} || $f->{'underline_thickness'} || $font->underlinethickness
$f->{"strikeline_thickness"} or $f->{"underline_thickness"}
MC/DC0%0/3
$f->{'strikeline_thickness'} || $f->{'underline_thickness'} || $font->underlinethickness
$f->{"strikeline_thickness"}
$f->{"underline_thickness"}
$font->underlinethickness
Truth table0%0/4
A or B || C
A= $f->{"strikeline_thickness"}B= $f->{"underline_thickness"}C= $font->underlinethickness
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | my $col = $fragment->{strikethrough_color} // $fragment->{color}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{"strikethrough_color"} // $fragment->{"color"}
MC/DC0%0/2
$fragment->{"strikethrough_color"} // $fragment->{"color"}
$fragment->{"strikethrough_color"}
$fragment->{"color"}
Truth table0%0/3
A // B
A= $fragment->{"strikethrough_color"}B= $fragment->{"color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | push( @strikes, [ $d+$h/2, $h, $col ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | if ( $fragment->{overline} && $fragment->{overline} ne 'none' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fragment->{"overline"} and $fragment->{"overline"} ne "none"
MC/DC0%0/2
$fragment->{"overline"} and $fragment->{"overline"} ne "none"
$fragment->{"overline"}
$fragment->{"overline"} ne "none"
Truth table33%1/3
A and B
A= $fragment->{"overline"}B= $fragment->{"overline"} ne "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | my $sz = $fragment->{size} || $self->{_currentsize}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table0%0/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $xh = $font->xheight / 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | my $h = ( $f->{overline_thickness} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | || $f->{underline_thickness} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | || $font->underlinethickness ) * $sz/$dw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$f->{'overline_thickness'} || $f->{'underline_thickness'} || $font->underlinethickness
$f->{"overline_thickness"} or $f->{"underline_thickness"}
MC/DC0%0/3
$f->{'overline_thickness'} || $f->{'underline_thickness'} || $font->underlinethickness
$f->{"overline_thickness"}
$f->{"underline_thickness"}
$font->underlinethickness
Truth table0%0/4
A or B || C
A= $f->{"overline_thickness"}B= $f->{"underline_thickness"}C= $font->underlinethickness
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | my $d = -( $f->{overline_position} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | ? $f->{overline_position} * $sz/$dw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | : $xh*$sz + 2*$h ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | my $col = $fragment->{overline_color} // $fragment->{color}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{"overline_color"} // $fragment->{"color"}
MC/DC0%0/2
$fragment->{"overline_color"} // $fragment->{"color"}
$fragment->{"overline_color"}
$fragment->{"color"}
Truth table0%0/3
A // B
A= $fragment->{"overline_color"}B= $fragment->{"color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( $fragment->{overline} eq 'double' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | push( @strikes, [ $d-0.125*$h, $h * 0.75, $col ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | [ $d+1.125*$h, $h * 0.75, $col ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | push( @strikes, [ $d+$h/2, $h, $col ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | ▶ | $text->textend if @strikes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | for ( @strikes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $gfx = $text; # prevent mental insanity | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $gfx->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $gfx->strokecolor($_->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $gfx->linewidth($_->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $gfx->move( $x0, $y0-$fragment->{base}-$bl-$_->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $gfx->line( $x, $y0-$fragment->{base}-$bl-$_->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $gfx->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $gfx->restore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | $text->textstart if @strikes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | ▶ | if ( $fragment->{href} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | my $sz = $fragment->{size} || $self->{_currentsize}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fragment->{'size'} || $self->{'_currentsize'}
MC/DC0%0/2
$fragment->{'size'} || $self->{'_currentsize'}
$fragment->{'size'}
$self->{'_currentsize'}
Truth table0%0/3
A || B
A= $fragment->{'size'}B= $self->{'_currentsize'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $ann = $text->{' apipage'}->annotation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $target = $fragment->{href}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ( $target =~ /^#(.+)/ ) { # named destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # Augmented API for apps that keep track of bookmarks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $pdf = $text->{' api'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ( my $c = $pdf->can("named_dest_fiddle") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $target = $pdf->$c($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $ann->link($target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # Named destination in other PDF. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | elsif ( $target =~ /^(?!\w{3,}:)(.*)\#(.+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $ann->pdf( $1, "/$2" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # Arbitrary document. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $ann->uri($target); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # $ann->border( 0, 0, 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $ann->rect( $x0, $y0, $x, $y0 + $bb[2] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | #### API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 4 | ▶ | sub bbox { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bbox: called CC=70 SCAR=74.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 4 | my ( $self, $all ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | my ( $bl, $x, $y, $w, $h ) = (0) x 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 4 | my ( $d, $a ) = (0) x 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 4 | my ( $xMin, $xMax, $yMin, $yMax ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | my $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 4 | $self->{_struts} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 4 | foreach ( @{ $self->{_content} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0&& | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | warn("IB: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | join(", ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 6 | map { defined($_) ? sprintf("%.2f", $_) : "<undef>" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | $xMin, $yMin, $xMax, $yMax ), "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 6 | ▶ | if ( $_->{type} eq "strut" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | my @ab = ( 0, -($_->{desc}//0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | ▶ | $_->{width}//0, $_->{asc}//0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$_->{"desc"} // 0
$_->{"width"} // 0
$_->{"asc"} // 0
MC/DC0%0/1
$_->{"desc"} // 0
$_->{"desc"}
MC/DC0%0/1
$_->{"width"} // 0
$_->{"width"}
MC/DC0%0/1
$_->{"asc"} // 0
$_->{"asc"}
Truth table50%1/2
A
A= $_->{"desc"}
Truth table50%1/2
A
A= $_->{"width"}
Truth table50%1/2
A
A= $_->{"asc"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | my %s = %$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | delete($s{type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2 | $s{_x} = $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2 | $s{_strut} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | push( @{ $self->{_struts} }, \%s ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # Add to bbox but not to inkbox. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | $w += $ab[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 2 | ▶ | $a = $ab[3] if $ab[3] > $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | ▶ | $d = $ab[1] if $ab[1] < $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | elsif ( my $hd = $self->get_element_handler($_->{type}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my @ab = @{$hd->bbox($_)->{abox}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | $xMin //= $w + $ab[0] if $all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$xMin //= $w + $ab[0]
MC/DC0%0/1
$xMin //= $w + $ab[0]
$xMin
Truth table0%0/2
A
A= $xMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $xMax = $w + $ab[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $w += $ab[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | $a = $ab[3] if $ab[3] > $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $d = $ab[1] if $ab[1] < $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | if ( $all ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $yMin = $ab[1] if !defined($yMin) || $ab[1] < $yMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $yMin or $ab[1] < $yMin
MC/DC0%0/2
not defined $yMin or $ab[1] < $yMin
not defined $yMin
$ab[1] < $yMin
Truth table0%0/3
not(A) or B
A= not defined $yMinB= $ab[1] < $yMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | $yMax = $ab[3] if !defined($yMax) || $ab[3] > $yMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $yMax or $ab[3] > $yMax
MC/DC0%0/2
not defined $yMax or $ab[3] > $yMax
not defined $yMax
$ab[3] > $yMax
Truth table0%0/3
not(A) or B
A= not defined $yMaxB= $ab[3] > $yMax
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 6 | ▶ | next unless $_->{type} eq "text" && length($_->{text}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_->{"type"} eq "text" and length $_->{"text"}
MC/DC50%1/2
$_->{"type"} eq "text" and length $_->{"text"}
$_->{"type"} eq "text"
length $_->{"text"}
Truth table66%2/3
A and B
A= $_->{"type"} eq "text"B= length $_->{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | my $f = $_->{font}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | my $font = $f->get_font($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 4 | ▶ | unless ( $font ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | carp("Can't happen?"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $f = $self->{_currentfont}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $font = $f->getfont($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 4 | my $upem = 1000; # as delivered by PDF::API2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 4 | my $size = $_->{size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 4 | my $base = $_->{base}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | ▶ | my $mydir = $f->{direction} || 'ltr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$f->{'direction'} || 'ltr'
MC/DC0%0/1
$f->{'direction'} || 'ltr'
$f->{'direction'}
Truth table50%1/2
A
A= $f->{'direction'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # Width and inkbox, if requested. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 4 | ▶ | if ( _hb_font_check( $f ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $hb->set_font( $font->fontfilename ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $hb->set_size($size); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $hb->set_language( $f->{language} ) if $f->{language}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | $hb->set_direction( $f->{direction} ) if $f->{direction}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $hb->set_text( $_->{text} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my $info = $hb->shaper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $mydir = $hb->get_direction; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # warn("mydir $mydir\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ( $all ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $ext = $hb->get_extents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | foreach my $g ( @$info ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $e = shift(@$ext); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | printf STDERR ( "G %3d %6.2f %6.2f %6.2f %6.2f %6.2f\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | $g->{g}, $g->{ax}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | @$e{ qw( x_bearing y_bearing width height ) } ) if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # It is easier to work with the baseline oriented box. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $e->{xMin} = $e->{x_bearing}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $e->{yMin} = $e->{y_bearing} + $e->{height} - $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $e->{xMax} = $e->{x_bearing} + $e->{width}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $e->{yMax} = $e->{y_bearing} - $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | $xMin //= $w + $e->{xMin} if $e->{width}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$xMin //= $w + $e->{"xMin"}
MC/DC0%0/1
$xMin //= $w + $e->{"xMin"}
$xMin
Truth table0%0/2
A
A= $xMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | $yMin = $e->{yMin} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if !defined($yMin) || $e->{yMin} < $yMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $yMin or $e->{"yMin"} < $yMin
MC/DC0%0/2
not defined $yMin or $e->{"yMin"} < $yMin
not defined $yMin
$e->{"yMin"} < $yMin
Truth table0%0/3
not(A) or B
A= not defined $yMinB= $e->{"yMin"} < $yMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | $yMax = $e->{yMax} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if !defined($yMax) || $e->{yMax} > $yMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $yMax or $e->{"yMax"} > $yMax
MC/DC0%0/2
not defined $yMax or $e->{"yMax"} > $yMax
not defined $yMax
$e->{"yMax"} > $yMax
Truth table0%0/3
not(A) or B
A= not defined $yMaxB= $e->{"yMax"} > $yMax
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $xMax = $w + $e->{xMax}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $w += $g->{ax}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | foreach my $g ( @$info ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $w += $g->{ax}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ▶ | elsif ( $all && $font->can("extents") ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$all and $font->can("extents")
MC/DC0%0/2
$all and $font->can("extents")
$all
$font->can("extents")
Truth table66%2/3
A and B
A= $allB= $font->can("extents")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | my $e = $font->extents( $_->{text}, $size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | printf STDERR ("(%.2f,%.2f)(%.2f,%.2f) -> ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/10
$all and 0
$xMin // 0
$yMin // 0
$xMax // 0
$yMax // 0
MC/DC0%0/1
$all and 0
$all
MC/DC0%0/1
$xMin // 0
$xMin
MC/DC0%0/1
$yMin // 0
$yMin
MC/DC0%0/1
$xMax // 0
$xMax
MC/DC0%0/1
$yMax // 0
$yMax
Truth table0%0/2
A
A= $all
Truth table0%0/2
A
A= $xMin
Truth table0%0/2
A
A= $yMin
Truth table0%0/2
A
A= $xMax
Truth table0%0/2
A
A= $yMax
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | $xMin//0, $yMin//0, $xMax//0, $yMax//0 ) if $all && 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | $xMax = $w + $e->{xMax} if $all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $w += $e->{wx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # warn("W \"", $_->{text}, "\" $w, ", $e->{width}, "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if ( $all ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $_ -= $base for $e->{yMin}, $e->{yMax}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # Baseline oriented box. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | $xMin //= $w - $e->{wx} + $e->{xMin}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$xMin //= $w - $e->{"wx"} + $e->{"xMin"}
MC/DC0%0/1
$xMin //= $w - $e->{"wx"} + $e->{"xMin"}
$xMin
Truth table0%0/2
A
A= $xMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | $yMin = $e->{yMin} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if !defined($yMin) || $e->{yMin} < $yMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $yMin or $e->{"yMin"} < $yMin
MC/DC0%0/2
not defined $yMin or $e->{"yMin"} < $yMin
not defined $yMin
$e->{"yMin"} < $yMin
Truth table0%0/3
not(A) or B
A= not defined $yMinB= $e->{"yMin"} < $yMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $yMax = $e->{yMax} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if !defined($yMax) || $e->{yMax} > $yMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $yMax or $e->{"yMax"} > $yMax
MC/DC0%0/2
not defined $yMax or $e->{"yMax"} > $yMax
not defined $yMax
$e->{"yMax"} > $yMax
Truth table0%0/3
not(A) or B
A= not defined $yMaxB= $e->{"yMax"} > $yMax
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | printf STDERR ("(%.2f,%.2f)(%.2f,%.2f)\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | $xMin//0, $yMin//0, $xMax//0, $yMax//0 ) if 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 4 | $w += $font->width( $_->{text} ) * $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | # We have width. Now the rest of the layoutbox. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 4 | my ( $d0, $a0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 4 | $d0 = $f->get_descender * $size / $upem - $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 4 | $a0 = $f->get_ascender * $size / $upem - $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | # Keep track of biggest decender/ascender. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 4 | ▶ | $d = $d0 if $d0 < $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 4 | ▶ | $a = $a0 if $a0 > $a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # Direction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 4 | ▶ | $dir //= $mydir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dir //= $mydir
MC/DC0%0/2
$dir //= $mydir
$dir
$mydir
Truth table33%1/3
A //= B
A= $dirB= $mydir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 4 | ▶ | $dir = 0 unless $dir eq $mydir; # mix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 4 | $bl = $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 4 | $h = $a - $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 4 | my $align = $self->{_alignment}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # warn("ALIGN: ", $align//"<unset>","\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 4 | ▶ | if ( $self->{_width} && $dir && $w < $self->{_width} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"_width"} and $dir and $w < $self->{"_width"}
$self->{"_width"} and $dir
MC/DC0%0/3
$self->{"_width"} and $dir and $w < $self->{"_width"}
$self->{"_width"}
$dir
$w < $self->{"_width"}
Truth table25%1/4
A and B and C
A= $self->{"_width"}B= $dirC= $w < $self->{"_width"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if ( $dir eq 'rtl' && (!$align || $align eq "left") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$dir eq "rtl" and !$align || $align eq "left"
not $align or $align eq "left"
MC/DC0%0/3
$dir eq "rtl" and !$align || $align eq "left"
$dir eq "rtl"
not $align
$align eq "left"
Truth table0%0/4
A and not(B) or C
A= $dir eq "rtl"B= not $alignC= $align eq "left"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $align = "right"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # warn("ALIGN: set to $align\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 4 | ▶ | if ( $self->{_width} && $align && $w < $self->{_width} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->{"_width"} and $align and $w < $self->{"_width"}
$self->{"_width"} and $align
MC/DC0%0/3
$self->{"_width"} and $align and $w < $self->{"_width"}
$self->{"_width"}
$align
$w < $self->{"_width"}
Truth table25%1/4
A and B and C
A= $self->{"_width"}B= $alignC= $w < $self->{"_width"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # warn("ALIGNING...\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if ( $align eq "right" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # warn("ALIGNING: to $align\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $x += my $d = $self->{_width} - $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | $xMin += $d if defined $xMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | $xMax += $d if defined $xMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | elsif ( $align eq "center" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # warn("ALIGNING: to $align\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $x += my $d = ( $self->{_width} - $w ) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | $xMin += $d if defined $xMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $xMax += $d if defined $xMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | ▶ | [ $bl, $x, $y-$h, $w, $h, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | defined $xMin ? ( $xMin, $yMin-$bl, $xMax-$xMin, $yMax-$yMin ) : ()]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | #### API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 3 | ▶ | sub load_font { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_font: called CC=14 SCAR=41.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 3 | my ( $self, $font, $fd ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | ▶ | if ( my $f = $fc->{$font} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # warn("Loaded font $font (cached)\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | $fd->{ascender} //= $f->ascender; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fd->{"ascender"} //= $f->ascender
MC/DC0%0/2
$fd->{"ascender"} //= $f->ascender
$fd->{"ascender"}
$f->ascender
Truth table0%0/3
A //= B
A= $fd->{"ascender"}B= $f->ascender
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | $fd->{descender} //= $f->descender; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fd->{"descender"} //= $f->descender
MC/DC0%0/2
$fd->{"descender"} //= $f->descender
$fd->{"descender"}
$f->descender
Truth table0%0/3
A //= B
A= $fd->{"descender"}B= $f->descender
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | return $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 3 | my $ff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 3 | ▶ | my $actual = Text::Layout::FontConfig->remap($font) // $font; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
"Text::Layout::FontConfig"->remap($font) // $font
MC/DC0%0/2
"Text::Layout::FontConfig"->remap($font) // $font
"Text::Layout::FontConfig"->remap($font)
$font
Truth table33%1/3
A // B
A= "Text::Layout::FontConfig"->remap($font)B= $font
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 3 | ▶ | if ( $actual =~ /\.[ot]tf$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | $ff = $self->{_context}->ttfont( $actual, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | -dokern => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | $fd->{nosubset} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | ? ( -nosubset => 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | : ( -nosubset => 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | elsif ( $actual =~ /(.*\.ttc)(?::(.*))?$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # This requires PDF::API2 augmentations. See below. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $file = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my $sel = $2 // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $ttc = $self->{_context}->ttc($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | $ff = $self->{_context}->ttcfont( $ttc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | font => $sel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | -dokern => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | $fd->{nosubset} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | ? ( -nosubset => 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | : ( -nosubset => 0 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 3 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 3 | $ff = $self->{_context}->corefont( $actual, -dokern => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 3 | ▶ | croak( "Cannot load font: ", $actual, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | $actual ne $font ? " (remapped from $font)" : "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | "\n", $@ ) unless $ff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # warn("Loaded font: $font\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 3 | $self->{font} = $ff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 3 | ▶ | $fd->{ascender} //= $ff->ascender; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$fd->{"ascender"} //= $ff->ascender
MC/DC0%0/2
$fd->{"ascender"} //= $ff->ascender
$fd->{"ascender"}
$ff->ascender
Truth table33%1/3
A //= B
A= $fd->{"ascender"}B= $ff->ascender
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | ▶ | $fd->{descender} //= $ff->descender; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$fd->{"descender"} //= $ff->descender
MC/DC0%0/2
$fd->{"descender"} //= $ff->descender
$fd->{"descender"}
$ff->descender
Truth table33%1/3
A //= B
A= $fd->{"descender"}B= $ff->descender
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 3 | $fc->{$font} = $ff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 3 | return $ff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | sub xheight { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xheight: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $_[0]->data->{xheight}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | sub bbextend { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bbextend: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my ( $cur, $bb, $dx, $dy ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | $dx //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dx //= 0
MC/DC0%0/1
$dx //= 0
$dx
Truth table0%0/2
A
A= $dx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | $dy //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dy //= 0
MC/DC0%0/1
$dy //= 0
$dy
Truth table0%0/2
A
A= $dy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if ( defined $cur->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $dx += $cur->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $dy += $cur->[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | $cur->[0] = $bb->[0] + $dx if $cur->[0] > $bb->[0] + $dx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | $cur->[1] = $bb->[1] + $dy if $cur->[1] > $bb->[1] + $dy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | $cur->[2] = $bb->[2] + $dx if $cur->[2] < $bb->[2] + $dx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | $cur->[3] = $bb->[3] + $dy if $cur->[3] < $bb->[3] + $dy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $cur->[0] = $bb->[0] + $dx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $cur->[1] = $bb->[1] + $dy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $cur->[2] = $bb->[2] + $dx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $cur->[3] = $bb->[3] + $dy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | return $cur; # for convenience | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | ################ Extensions to PDF::API2 ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | sub PDF::API2::Content::glyph_by_CId { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
glyph_by_CId: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my ( $self, $cid ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $self->add( sprintf("<%04x> Tj", $cid ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $self->{' font'}->fontfile->subsetByCId($cid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # HarfBuzz requires a TT/OT font. Define the fontfilename method only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | # for classes that HarfBuzz can deal with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | sub PDF::API2::Resource::CIDFont::TrueType::fontfilename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fontfilename: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $self->fontfile->{' font'}->{' fname'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # Add extents calculation for CIDfonts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # Note: Origin is x=0 at the baseline. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 1 | ▶ | sub PDF::API2::Resource::CIDFont::extents { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extents: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 1 | my ( $self, $text, $size ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 1 | ▶ | $size //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$size //= 1
MC/DC0%0/1
$size //= 1
$size
Truth table50%1/2
A
A= $size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 1 | my $e = $self->extents_cid( $self->cidsByStr($text), $size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 1 | return $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | ▶ | sub PDF::API2::Resource::CIDFont::extents_cid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extents_cid: called CC=18 SCAR=32.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 1 | my ( $self, $text, $size ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | my $width = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | my ( $xMin, $xMax, $yMin, $yMax, $bl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | my $upem = $self->data->{upem}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | my $glyphs = $self->fontobj->{loca}->read->{glyphs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | $bl = $self->ascender; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | my $lastglyph = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | my $lastwidth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | # Fun ahead! Widths are in 1000 and xMin and such in upem. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # Scale to 1000ths. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 1 | my $scale = 1000 / $upem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | foreach my $n (unpack('n*', $text)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 19 | $width += $lastwidth = $self->wxByCId($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 19 | ▶ | if ($self->{'-dokern'} and $self->haveKernPairs()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"-dokern"} and $self->haveKernPairs
MC/DC0%0/2
$self->{"-dokern"} and $self->haveKernPairs
$self->{"-dokern"}
$self->haveKernPairs
Truth table33%1/3
A and B
A= $self->{"-dokern"}B= $self->haveKernPairs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | if ($self->kernPairCid($lastglyph, $n)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $width -= $self->kernPairCid($lastglyph, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 19 | $lastglyph = $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 19 | my $ex = $glyphs->[$n]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 19 | ▶ | unless ( defined $ex && %$ex ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ex and %$ex
MC/DC0%0/2
defined $ex and %$ex
defined $ex
%$ex
Truth table33%1/3
A and B
A= defined $exB= %$ex
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | warn("Missing glyph: $n\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 19 | $ex->read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 19 | my $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # Copy while scaling. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 19 | $e->{$_} = $ex->{$_} * $scale for qw( xMin yMin xMax yMax ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | printf STDERR ( "G %3d %6.2f %6.2f %6.2f %6.2f %6.2f\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | $n, $lastwidth, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 19 | @$e{ qw( xMin yMin xMax yMax ) } ) if 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 19 | ▶ | $xMin //= ($width - $lastwidth) + $e->{xMin}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$xMin //= $width - $lastwidth + $e->{"xMin"}
MC/DC100%1/1
$xMin //= $width - $lastwidth + $e->{"xMin"}
$xMin
Truth table100%2/2
A
A= $xMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 19 | ▶ | $yMin = $e->{yMin} if !defined($yMin) || $e->{yMin} < $yMin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $yMin or $e->{"yMin"} < $yMin
MC/DC100%2/2
not defined $yMin or $e->{"yMin"} < $yMin
not defined $yMin
$e->{"yMin"} < $yMin
Truth table100%3/3
not(A) or B
A= not defined $yMinB= $e->{"yMin"} < $yMin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 19 | ▶ | $yMax = $e->{yMax} if !defined($yMax) || $e->{yMax} > $yMax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $yMax or $e->{"yMax"} > $yMax
MC/DC50%1/2
not defined $yMax or $e->{"yMax"} > $yMax
not defined $yMax
$e->{"yMax"} > $yMax
Truth table66%2/3
not(A) or B
A= not defined $yMaxB= $e->{"yMax"} > $yMax
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 19 | $xMax = ($width - $lastwidth) + $e->{xMax}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1 | ▶ | if ( defined $lastwidth ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # $xMax += ($width - $lastwidth); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $xMin = $yMin = $xMax = $yMax = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | $width = $self->missingwidth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 1 | ▶ | $_ = ($_//0)*$size/1000 for $xMin, $xMax, $yMin, $yMax, $bl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ // 0
MC/DC0%0/1
$_ // 0
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 1 | ▶ | $_ = ($_//0)*$size/1000 for $width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ // 0
MC/DC0%0/1
$_ // 0
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | return { x => $xMin, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | y => $yMin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | width => $xMax - $xMin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | height => $yMax - $yMin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # These are for convenience | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | xMin => $xMin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | yMin => $yMin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | xMax => $xMax, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | yMax => $yMax, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | wx => $width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | bl => $bl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # Note: This is an augmented copy of the method from PDF::API2 2.047. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 5 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 5 | ▶ | use PDF::API2::Resource::CIDFont::TrueType::FontFile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 1 | ▶ | sub PDF::API2::Resource::CIDFont::TrueType::FontFile::new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=43 SCAR=45.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | package PDF::API2::Resource::CIDFont::TrueType::FontFile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 1 | my ($class, $pdf, $file, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | #### Start of changes #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 5 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 1 | my $font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # If the file is already a suitable font object, use it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | ▶ | if ( UNIVERSAL::isa( $file, 'Font::TTF::Font' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $font = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 1 | ▶ | confess "cannot find font '$file'" unless -f $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 1 | $font = Font::TTF::Font->open($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | #### End of changes #### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | $data->{'obj'} = $font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | ▶ | $class = ref($class) if ref($class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | $self->{'Filter'} = PDFArray(PDFName('FlateDecode')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 1 | $self->{' font'} = $font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 1 | $self->{' data'} = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | ▶ | $data->{'noembed'} = $opts{'embed'} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | ▶ | $data->{'iscff'} = defined($font->{'CFF '}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | ▶ | $self->{'Subtype'} = PDFName('CIDFontType0C') if $data->{'iscff'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 1 | $data->{'fontfamily'} = $font->{'name'}->read->find_name(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | $data->{'fontname'} = $font->{'name'}->read->find_name(4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 1 | $font->{'OS/2'}->read(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 1 | my @stretch = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | Normal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | UltraCondensed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | ExtraCondensed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | Condensed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | SemiCondensed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | Normal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | SemiExpanded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | Expanded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | ExtraExpanded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | UltraExpanded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | ▶ | $data->{'fontstretch'} = $stretch[$font->{'OS/2'}->{'usWidthClass'}] || 'Normal'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$stretch[$font->{'OS/2'}{'usWidthClass'}] || 'Normal'
MC/DC0%0/1
$stretch[$font->{'OS/2'}{'usWidthClass'}] || 'Normal'
$stretch[$font->{'OS/2'}{'usWidthClass'}]
Truth table50%1/2
A
A= $stretch[$font->{'OS/2'}{'usWidthClass'}]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 1 | $data->{'fontweight'} = $font->{'OS/2'}->{'usWeightClass'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 1 | $data->{'panose'} = pack('n', $font->{'OS/2'}->{'sFamilyClass'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 1 | foreach my $p (qw[bFamilyType bSerifStyle bWeight bProportion bContrast bStrokeVariation bArmStyle bLetterform bMidline bXheight]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 10 | $data->{'panose'} .= pack('C', $font->{'OS/2'}->{$p}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | $data->{'apiname'} = join('', map { ucfirst(lc(substr($_, 0, 2))) } split m/[^A-Za-z0-9\s]+/, $data->{'fontname'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | $data->{'fontname'} =~ s/[\x00-\x1f\s]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | $data->{'altname'} = $font->{'name'}->find_name(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 1 | $data->{'altname'} =~ s/[\x00-\x1f\s]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 1 | $data->{'subname'} = $font->{'name'}->find_name(2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 1 | $data->{'subname'} =~ s/[\x00-\x1f\s]//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 1 | $font->{'cmap'}->read->find_ms(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 1 | ▶ | if (defined $font->{'cmap'}->find_ms()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 1 | ▶ | $data->{'issymbol'} = ($font->{'cmap'}->find_ms->{'Platform'} == 3 and $font->{'cmap'}->read->find_ms->{'Encoding'} == 0) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$font->{'cmap'}->find_ms->{'Platform'} == 3 && $font->{'cmap'}->read->find_ms->{'Encoding'} == 0 || 0
$font->{"cmap"}->find_ms->{"Platform"} == 3 and $font->{"cmap"}->read->find_ms->{"Encoding"} == 0
MC/DC0%0/2
$font->{'cmap'}->find_ms->{'Platform'} == 3 && $font->{'cmap'}->read->find_ms->{'Encoding'} == 0 || 0
$font->{"cmap"}->find_ms->{"Platform"} == 3
$font->{"cmap"}->read->find_ms->{"Encoding"} == 0
Truth table33%1/3
A and B
A= $font->{"cmap"}->find_ms->{"Platform"} == 3B= $font->{"cmap"}->read->find_ms->{"Encoding"} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $data->{'issymbol'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 1 | $data->{'upem'} = $font->{'head'}->read->{'unitsPerEm'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | $data->{'fontbbox'} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | int($font->{'head'}->{'xMin'} * 1000 / $data->{'upem'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | int($font->{'head'}->{'yMin'} * 1000 / $data->{'upem'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | int($font->{'head'}->{'xMax'} * 1000 / $data->{'upem'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 1 | int($font->{'head'}->{'yMax'} * 1000 / $data->{'upem'}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 1 | $data->{'stemv'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | $data->{'stemh'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | ▶ | $data->{'missingwidth'} = int($font->{'hhea'}->read->{'advanceWidthMax'} * 1000 / $data->{'upem'}) || 1000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
int $font->{'hhea'}->read->{'advanceWidthMax'} * 1000 / $data->{'upem'} || 1000
MC/DC0%0/1
int $font->{'hhea'}->read->{'advanceWidthMax'} * 1000 / $data->{'upem'} || 1000
int $font->{'hhea'}->read->{'advanceWidthMax'} * 1000 / $data->{'upem'}
Truth table50%1/2
A
A= int $font->{'hhea'}->read->{'advanceWidthMax'} * 1000 / $data->{'upem'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | $data->{'maxwidth'} = int($font->{'hhea'}->{'advanceWidthMax'} * 1000 / $data->{'upem'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1 | $data->{'ascender'} = int($font->{'hhea'}->read->{'Ascender'} * 1000 / $data->{'upem'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | $data->{'descender'} = int($font->{'hhea'}{'Descender'} * 1000 / $data->{'upem'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | $data->{'flags'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 1 | ▶ | $data->{'flags'} |= 1 if $font->{'OS/2'}->read->{'bProportion'} == 9; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 1 | ▶ | $data->{'flags'} |= 2 unless $font->{'OS/2'}{'bSerifStyle'} > 10 and $font->{'OS/2'}{'bSerifStyle'} < 14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$font->{"OS/2"}{"bSerifStyle"} > 10 and $font->{"OS/2"}{"bSerifStyle"} < 14
MC/DC0%0/2
$font->{"OS/2"}{"bSerifStyle"} > 10 and $font->{"OS/2"}{"bSerifStyle"} < 14
$font->{"OS/2"}{"bSerifStyle"} > 10
$font->{"OS/2"}{"bSerifStyle"} < 14
Truth table33%1/3
A and B
A= $font->{"OS/2"}{"bSerifStyle"} > 10B= $font->{"OS/2"}{"bSerifStyle"} < 14
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 1 | ▶ | $data->{'flags'} |= 8 if $font->{'OS/2'}{'bFamilyType'} == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 1 | $data->{'flags'} |= 32; # if $font->{'OS/2'}{'bFamilyType'} > 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | ▶ | $data->{'flags'} |= 64 if $font->{'OS/2'}{'bLetterform'} > 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 1 | ▶ | $data->{'capheight'} = $font->{'OS/2'}->{'CapHeight'} || int($data->{'fontbbox'}->[3] * 0.8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$font->{'OS/2'}{'CapHeight'} || int $data->{'fontbbox'}[3] * 0.8
MC/DC0%0/2
$font->{'OS/2'}{'CapHeight'} || int $data->{'fontbbox'}[3] * 0.8
$font->{'OS/2'}{'CapHeight'}
int $data->{'fontbbox'}[3] * 0.8
Truth table33%1/3
A || B
A= $font->{'OS/2'}{'CapHeight'}B= int $data->{'fontbbox'}[3] * 0.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | ▶ | $data->{'xheight'} = $font->{'OS/2'}->{'xHeight'} || int($data->{'fontbbox'}->[3] * 0.4); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$font->{'OS/2'}{'xHeight'} || int $data->{'fontbbox'}[3] * 0.4
MC/DC0%0/2
$font->{'OS/2'}{'xHeight'} || int $data->{'fontbbox'}[3] * 0.4
$font->{'OS/2'}{'xHeight'}
int $data->{'fontbbox'}[3] * 0.4
Truth table33%1/3
A || B
A= $font->{'OS/2'}{'xHeight'}B= int $data->{'fontbbox'}[3] * 0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 1 | ▶ | if ($data->{'issymbol'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | $data->{'e2u'} = [0xf000 .. 0xf0ff]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 1 | $data->{'e2u'} = [unpack('U*', decode('cp1252', pack('C*', 0 .. 255)))]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 1 | ▶ | if ($font->{'post'}->read->{'FormatType'} == 3 and defined $font->{'cmap'}->read->find_ms()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$font->{"post"}->read->{"FormatType"} == 3 and defined $font->{"cmap"}->read->find_ms
MC/DC0%0/2
$font->{"post"}->read->{"FormatType"} == 3 and defined $font->{"cmap"}->read->find_ms
$font->{"post"}->read->{"FormatType"} == 3
defined $font->{"cmap"}->read->find_ms
Truth table33%1/3
A and B
A= $font->{"post"}->read->{"FormatType"} == 3B= defined $font->{"cmap"}->read->find_ms
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $data->{'g2n'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | foreach my $u (sort { $a <=> $b } keys %{$font->{'cmap'}->read->find_ms->{'val'}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $n = nameByUni($u); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | $data->{'g2n'}->[$font->{'cmap'}->read->find_ms->{'val'}->{$u}] = $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 1 | ▶ | $data->{'g2n'} = [ map { $_ || '.notdef' } @{$font->{'post'}->read->{'VAL'}} ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_ || '.notdef'
MC/DC0%0/1
$_ || '.notdef'
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 1 | $data->{'italicangle'} = $font->{'post'}->{'italicAngle'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 1 | $data->{'isfixedpitch'} = $font->{'post'}->{'isFixedPitch'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 1 | $data->{'underlineposition'} = $font->{'post'}->{'underlinePosition'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 1 | $data->{'underlinethickness'} = $font->{'post'}->{'underlineThickness'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 1 | ▶ | if ($self->iscff()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $data->{'cff'} = readcffstructs($font); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | ▶ | if (defined $data->{'cff'}->{'ROS'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | my %cffcmap = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 'Adobe:Japan1' => 'japanese', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 'Adobe:Korea1' => 'korean', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 'Adobe:CNS1' => 'traditional', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 'Adobe:GB1' => 'simplified', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | my $key = $data->{'cff'}->{'ROS'}->[0] . ':' . $data->{'cff'}->{'ROS'}->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | my $ccmap = _look_for_cmap($cffcmap{$key} // $key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$cffcmap{$key} // $key
MC/DC0%0/2
$cffcmap{$key} // $key
$cffcmap{$key}
$key
Truth table0%0/3
A // B
A= $cffcmap{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | $data->{'u2g'} = $ccmap->{'u2g'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $data->{'g2u'} = $ccmap->{'g2u'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 1 | $data->{'u2g'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 1 | my $gmap = $font->{'cmap'}->read->find_ms->{'val'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 1 | foreach my $u (sort {$a <=> $b} keys %$gmap) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 245 | ▶ | my $uni = $u || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$u || 0
MC/DC0%0/1
$u || 0
$u
Truth table50%1/2
A
A= $u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 245 | $data->{'u2g'}->{$uni} = $gmap->{$uni}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 1 | ▶ | $data->{'g2u'} = [ map { $_ || 0 } $font->{'cmap'}->read->reverse() ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_ || 0
MC/DC100%1/1
$_ || 0
$_
Truth table100%2/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 1 | ▶ | if ($data->{'issymbol'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | map { $data->{'u2g'}->{$_} ||= $font->{'cmap'}->read->ms_lookup($_) } (0xf000 .. 0xf0ff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{"u2g"}{$_} ||= $font->{"cmap"}->read->ms_lookup($_)
MC/DC0%0/2
$data->{"u2g"}{$_} ||= $font->{"cmap"}->read->ms_lookup($_)
$data->{"u2g"}{$_}
$font->{"cmap"}->read->ms_lookup($_)
Truth table0%0/3
A ||= B
A= $data->{"u2g"}{$_}B= $font->{"cmap"}->read->ms_lookup($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | map { $data->{'u2g'}->{$_ & 0xff} ||= $font->{'cmap'}->read->ms_lookup($_) } (0xf000 .. 0xf0ff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{"u2g"}{$_ & 255} ||= $font->{"cmap"}->read->ms_lookup($_)
MC/DC0%0/2
$data->{"u2g"}{$_ & 255} ||= $font->{"cmap"}->read->ms_lookup($_)
$data->{"u2g"}{$_ & 255}
$font->{"cmap"}->read->ms_lookup($_)
Truth table0%0/3
A ||= B
A= $data->{"u2g"}{$_ & 255}B= $font->{"cmap"}->read->ms_lookup($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 1 | ▶ | $data->{'e2n'} = [ map { $data->{'g2n'}->[$data->{'u2g'}->{$_} || 0] || '.notdef' } @{$data->{'e2u'}} ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$data->{'g2n'}[$data->{'u2g'}{$_} or 0] || '.notdef'
$data->{'u2g'}{$_} || 0
MC/DC0%0/1
$data->{'g2n'}[$data->{'u2g'}{$_} or 0] || '.notdef'
$data->{'g2n'}[$data->{'u2g'}{$_} or 0]
MC/DC100%1/1
$data->{'u2g'}{$_} || 0
$data->{'u2g'}{$_}
Truth table50%1/2
A
A= $data->{'g2n'}[$data->{'u2g'}{$_} or 0]
Truth table100%2/2
A
A= $data->{'u2g'}{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 1 | ▶ | $data->{'e2g'} = [ map { $data->{'u2g'}->{$_ || 0} || 0 } @{$data->{'e2u'}} ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$data->{'u2g'}{$_ or 0} || 0
$_ || 0
MC/DC100%1/1
$data->{'u2g'}{$_ or 0} || 0
$data->{'u2g'}{$_ or 0}
MC/DC100%1/1
$_ || 0
$_
Truth table100%2/2
A
A= $data->{'u2g'}{$_ or 0}
Truth table100%2/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 1 | $data->{'u2e'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 1 | foreach my $n (reverse 0 .. 255) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 256 | ▶ | $data->{'u2e'}->{$data->{'e2u'}->[$n]} //= $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$data->{"u2e"}{$data->{"e2u"}[$n]} //= $n
MC/DC0%0/2
$data->{"u2e"}{$data->{"e2u"}[$n]} //= $n
$data->{"u2e"}{$data->{"e2u"}[$n]}
$n
Truth table66%2/3
A //= B
A= $data->{"u2e"}{$data->{"e2u"}[$n]}B= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 1 | $data->{'u2n'} = { map { $data->{'g2u'}->[$_] => $data->{'g2n'}->[$_] } (0 .. (scalar @{$data->{'g2u'}} - 1)) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 1 | $data->{'wx'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 1 | foreach my $i (0 .. (scalar @{$data->{'g2u'}} - 1)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 262 | my $hmtx = $font->{'hmtx'}->read->{'advance'}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 262 | ▶ | if ($hmtx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 261 | $data->{'wx'}->[$i] = int($hmtx * 1000 / $data->{'upem'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 1 | $data->{'wx'}->[$i] = $data->{'missingwidth'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 1 | $data->{'kern'} = read_kern_table($font, $data->{'upem'}, $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 1 | ▶ | delete $data->{'kern'} unless defined $data->{'kern'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 1 | $data->{'fontname'} =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 1 | $data->{'fontfamily'} =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 1 | $data->{'apiname'} =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 1 | $data->{'altname'} =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 1 | $data->{'subname'} =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 1 | $self->subsetByCId(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 1 | return ($self, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 5 | ▶ | use warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # These are additions. Methods of $pdf for convenience. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | # Open a TTC (TrueType font Collection) file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | # This is not really API related, but it is handy to use the API file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | # lookups. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | # Returns a Font::TTF::Ttc object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | sub PDF::API2::ttc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ttc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my ( $self, $name, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | my $file = $self->can("_find_font")->($name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | or croak "Unable to find ttc \"$name\""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | require Font::TTF::Font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | require Font::TTF::Ttc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | return Font::TTF::Ttc->open($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # Create a API font from one of ttc fonts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # The font is selected with a C<font> option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # Font selectors are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # * The PostScript name of the font (case insensitive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # * The family name : style (case insensitive), where both may be omitted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # to select the first matching. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | # Note that the style must match what is in the font. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # E.g. "bold italic" (with a space, in this order). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | # If no font option is given, the first font found is used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 5 | our @CARP_NOT = qw( ChordPro::Logger ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | ▶ | sub PDF::API2::ttcfont { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ttcfont: not called CC=14 SCAR=51.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my ( $self, $ttc, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 5 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | my $sel = delete $opts{font} // ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $opts{"font"} // ""
MC/DC0%0/1
delete $opts{"font"} // ""
delete $opts{"font"}
Truth table0%0/2
A
A= delete $opts{"font"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | my $font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | foreach my $d ( @{ $ttc->{directs} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $d->{name}->read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | if ( $sel =~ /^(.*):(.*)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | next if $1 && lc($d->{name}->find_name(1)) ne lc($1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$1 and lc $d->{"name"}->find_name(1) ne lc $1
MC/DC0%0/2
$1 and lc $d->{"name"}->find_name(1) ne lc $1
$1
lc $d->{"name"}->find_name(1) ne lc $1
Truth table0%0/3
A and B
A= $1B= lc $d->{"name"}->find_name(1) ne lc $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | next if $2 && lc($d->{name}->find_name(2)) ne lc($2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$2 and lc $d->{"name"}->find_name(2) ne lc $2
MC/DC0%0/2
$2 and lc $d->{"name"}->find_name(2) ne lc $2
$2
lc $d->{"name"}->find_name(2) ne lc $2
Truth table0%0/3
A and B
A= $2B= lc $d->{"name"}->find_name(2) ne lc $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | elsif ( $sel ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | ▶ | next unless lc($d->{name}->find_name(6)) eq lc($sel); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | # else: use first found. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | $font = $d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | confess "Missing font '$sel' in ttcfont" unless $font; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | $opts{-unicodemap} = 1 unless exists $opts{-unicodemap}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | $opts{embed} = 1 unless exists $opts{embed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | require PDF::API2::Resource::CIDFont::TrueType; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | my $obj = PDF::API2::Resource::CIDFont::TrueType->new($self->{'pdf'}, $font, %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | $self->{'pdf'}->out_obj($self->{'pages'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | ▶ | $obj->tounicodemap() if $opts{-unicodemap}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | ################ Extensions to PDF::Builder ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | sub PDF::Builder::Content::glyph_by_CId { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
glyph_by_CId: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my ( $self, $cid ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | $self->add( sprintf("<%04x> Tj", $cid ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | $self->{' font'}->fontfile->subsetByCId($cid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | # HarfBuzz requires a TT/OT font. Define the fontfilename method only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | # for classes that HarfBuzz can deal with. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | sub PDF::Builder::Resource::CIDFont::TrueType::fontfilename { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fontfilename: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | $self->fontfile->{' font'}->{' fname'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | ################ For debugging/convenience ################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # Shows the bounding box of the last piece of text that was rendered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | sub showbb { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
showbb: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my ( $self, $gfx, $x, $y, $col ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | $x //= $self->{_lastx}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$x //= $self->{"_lastx"}
MC/DC0%0/2
$x //= $self->{"_lastx"}
$x
$self->{"_lastx"}
Truth table0%0/3
A //= B
A= $xB= $self->{"_lastx"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | $y //= $self->{_lasty}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$y //= $self->{"_lasty"}
MC/DC0%0/2
$y //= $self->{"_lasty"}
$y
$self->{"_lasty"}
Truth table0%0/3
A //= B
A= $yB= $self->{"_lasty"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | $col ||= "magenta"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$col ||= "magenta"
MC/DC0%0/1
$col ||= "magenta"
$col
Truth table0%0/2
A
A= $col
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | my ( $ink, $bb ) = $self->get_pixel_extents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | my $bl = $bb->{bl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # Bounding box, top-left coordinates. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | printf( "Ink: %6.2f %6.2f %6.2f %6.2f\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | @$ink{qw( x y width height )} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | printf( "Layout: %6.2f %6.2f %6.2f %6.2f BL %.2f\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | @$bb{qw( x y width height )}, $bl ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | # NOTE: Some fonts include natural spacing in the bounding box. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | # NOTE: Some fonts exclude accents on capitals from the bounding box. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | $gfx->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | $gfx->translate( $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | # Show origin. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | _showloc($gfx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | # Show baseline. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | _line( $gfx, $bb->{x}, -$bl, $bb->{width}, 0, $col ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | $gfx->restore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | # Show layout box. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $gfx->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $gfx->linewidth( 0.25 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | $gfx->strokecolor($col); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | $gfx->translate( $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | for my $e ( $bb ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | $gfx->rect( @$e{ qw( x y width height ) } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $gfx->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | $gfx->restore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | # Show ink box. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | $gfx->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | $gfx->linewidth( 0.25 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $gfx->strokecolor("cyan"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | $gfx->translate( $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | for my $e ( $ink ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | $gfx->rect( @$e{ qw( x y width height ) } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | $gfx->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | $gfx->restore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | ▶ | sub _showloc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_showloc: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | my ( $gfx, $x, $y, $d, $col ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | $x ||= 0; $y ||= 0; $d ||= 50; $col ||= "blue"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$x ||= 0
$y ||= 0
$d ||= 50
$col ||= "blue"
MC/DC0%0/1
$x ||= 0
$x
MC/DC0%0/1
$y ||= 0
$y
MC/DC0%0/1
$d ||= 50
$d
MC/DC0%0/1
$col ||= "blue"
$col
Truth table0%0/2
A
A= $x
Truth table0%0/2
A
A= $y
Truth table0%0/2
A
A= $d
Truth table0%0/2
A
A= $col
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | _line( $gfx, $x-$d, $y, 2*$d, 0, $col ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | _line( $gfx, $x, $y-$d, 0, 2*$d, $col ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | ▶ | sub _line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_line: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my ( $gfx, $x, $y, $w, $h, $col, $lw ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | $col ||= "black"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$col ||= "black"
MC/DC0%0/1
$col ||= "black"
$col
Truth table0%0/2
A
A= $col
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | $lw ||= 0.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$lw ||= "0.5"
MC/DC0%0/1
$lw ||= "0.5"
$lw
Truth table0%0/2
A
A= $lw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | $gfx->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | $gfx->move( $x, $y ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | $gfx->line( $x+$w, $y+$h ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | $gfx->linewidth($lw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | $gfx->strokecolor($col); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | $gfx->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | $gfx->restore; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||