| 1 | package HTML::FormatPS; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Format HTML as PostScript | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Encode; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use IO::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use utf8; # for the is_utf8 function | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use base 'HTML::Formatter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | our $VERSION = '2.16'; # VERSION | |||||||||||||||||||||||||||
| 17 | 3 | our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # We now use Smart::Comments in place of the old DEBUG framework. | ||||||||||||||||||||||||||||
| 20 | # this should be commented out in release versions.... | ||||||||||||||||||||||||||||
| 21 | ##use Smart::Comments; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 24 | # A few routines that convert lengths into points | ||||||||||||||||||||||||||||
| 25 | 50 | ▶ | sub mm { $_[0] * 72 / 25.4; } | ||||||||||||||||||||||||||
|
Subroutine
mm: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 42 | ▶ | sub in { $_[0] * 72; } | ||||||||||||||||||||||||||
|
Subroutine
in: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 29 | 3 | my %PaperSizes = ( | |||||||||||||||||||||||||||
| 30 | A3 => [ mm(297), mm(420) ], | ||||||||||||||||||||||||||||
| 31 | A4 => [ mm(210), mm(297) ], | ||||||||||||||||||||||||||||
| 32 | A5 => [ mm(148), mm(210) ], | ||||||||||||||||||||||||||||
| 33 | B4 => [ 729, 1032 ], | ||||||||||||||||||||||||||||
| 34 | B5 => [ 516, 729 ], | ||||||||||||||||||||||||||||
| 35 | Letter => [ in(8.5), in(11) ], | ||||||||||||||||||||||||||||
| 36 | Legal => [ in(8.5), in(14) ], | ||||||||||||||||||||||||||||
| 37 | Executive => [ in(7.5), in(10) ], | ||||||||||||||||||||||||||||
| 38 | Tabloid => [ in(11), in(17) ], | ||||||||||||||||||||||||||||
| 39 | Statement => [ in(5.5), in(8.5) ], | ||||||||||||||||||||||||||||
| 40 | Folio => [ in(8.5), in(13) ], | ||||||||||||||||||||||||||||
| 41 | "10x14" => [ in(10), in(14) ], | ||||||||||||||||||||||||||||
| 42 | Quarto => [ 610, 780 ], | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 46 | 3 | my %FontFamilies = ( | |||||||||||||||||||||||||||
| 47 | Courier => [ | ||||||||||||||||||||||||||||
| 48 | qw(Courier | ||||||||||||||||||||||||||||
| 49 | Courier-Bold | ||||||||||||||||||||||||||||
| 50 | Courier-Oblique | ||||||||||||||||||||||||||||
| 51 | Courier-BoldOblique) | ||||||||||||||||||||||||||||
| 52 | ], | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Helvetica => [ | ||||||||||||||||||||||||||||
| 55 | qw(Helvetica | ||||||||||||||||||||||||||||
| 56 | Helvetica-Bold | ||||||||||||||||||||||||||||
| 57 | Helvetica-Oblique | ||||||||||||||||||||||||||||
| 58 | Helvetica-BoldOblique) | ||||||||||||||||||||||||||||
| 59 | ], | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Times => [ | ||||||||||||||||||||||||||||
| 62 | qw(Times-Roman | ||||||||||||||||||||||||||||
| 63 | Times-Bold | ||||||||||||||||||||||||||||
| 64 | Times-Italic | ||||||||||||||||||||||||||||
| 65 | Times-BoldItalic) | ||||||||||||||||||||||||||||
| 66 | ], | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 70 | # size 0 1 2 3 4 5 6 7 8 | ||||||||||||||||||||||||||||
| 71 | 3 | my @FontSizes = ( 5, 6, 8, 10, 12, 14, 18, 24, 32 ); | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 13 | ▶ | sub BOLD { 0x01; } | ||||||||||||||||||||||||||
|
Subroutine
BOLD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 74 | 5 | ▶ | sub ITALIC { 0x02; } | ||||||||||||||||||||||||||
|
Subroutine
ITALIC: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 3 | my %param = ( | |||||||||||||||||||||||||||
| 77 | papersize => 'papersize', | ||||||||||||||||||||||||||||
| 78 | paperwidth => 'paperwidth', | ||||||||||||||||||||||||||||
| 79 | paperheight => 'paperheigth', | ||||||||||||||||||||||||||||
| 80 | leftmargin => 'lmW', | ||||||||||||||||||||||||||||
| 81 | rightmargin => 'rmW', | ||||||||||||||||||||||||||||
| 82 | horizontalmargin => 'mW', | ||||||||||||||||||||||||||||
| 83 | topmargin => 'tmH', | ||||||||||||||||||||||||||||
| 84 | bottommargin => 'bmH', | ||||||||||||||||||||||||||||
| 85 | verticalmargin => 'mH', | ||||||||||||||||||||||||||||
| 86 | no_prolog => 'no_prolog', | ||||||||||||||||||||||||||||
| 87 | no_trailer => 'no_trailer', | ||||||||||||||||||||||||||||
| 88 | pageno => 'printpageno', | ||||||||||||||||||||||||||||
| 89 | startpage => 'startpage', | ||||||||||||||||||||||||||||
| 90 | fontfamily => 'family', | ||||||||||||||||||||||||||||
| 91 | fontscale => 'fontscale', | ||||||||||||||||||||||||||||
| 92 | leading => 'leading', | ||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | 8 | my $class = shift; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 8 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # Obtained from the <title> element | ||||||||||||||||||||||||||||
| 104 | 8 | $self->{title} = ""; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | # The font ID last sent to the PostScript output (this may be | ||||||||||||||||||||||||||||
| 107 | # temporarily different from the "current font" as read from | ||||||||||||||||||||||||||||
| 108 | # the HTML input). Initially none. | ||||||||||||||||||||||||||||
| 109 | 8 | $self->{psfontid} = ""; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # Pending horizontal space. A list [ " ", $fontid, $width ], | ||||||||||||||||||||||||||||
| 112 | # or undef if no space is pending. | ||||||||||||||||||||||||||||
| 113 | 8 | $self->{hspace} = undef; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | # add an encoder object for perl native to Latin1 output | ||||||||||||||||||||||||||||
| 116 | 8 | $self->{encoder} = find_encoding('iso-8859-1'); | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 8 | $self; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 122 | 8 | ▶ | sub default_values { | ||||||||||||||||||||||||||
|
Subroutine
default_values: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 123 | 8 | ( shift->SUPER::default_values(), | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | family => "Times", | ||||||||||||||||||||||||||||
| 126 | mH => mm(40), | ||||||||||||||||||||||||||||
| 127 | mW => mm(20), | ||||||||||||||||||||||||||||
| 128 | printpageno => 1, | ||||||||||||||||||||||||||||
| 129 | startpage => 1, # yes, you can start numbering at 10, or whatever. | ||||||||||||||||||||||||||||
| 130 | fontscale => 1, | ||||||||||||||||||||||||||||
| 131 | leading => 0.1, | ||||||||||||||||||||||||||||
| 132 | papersize => 'A4', | ||||||||||||||||||||||||||||
| 133 | paperwidth => mm(210), | ||||||||||||||||||||||||||||
| 134 | paperheight => mm(297), | ||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 139 | 1 | ▶ | sub configure { | ||||||||||||||||||||||||||
|
Subroutine
configure: called CC=7 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 140 | 1 | my ( $self, $hash ) = @_; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 1 | my ( $key, $val ); | |||||||||||||||||||||||||||
| 143 | 1 | ▶ | while ( ( $key, $val ) = each %$hash ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 2 | $key = lc $key; | |||||||||||||||||||||||||||
| 145 | 2 | ▶ | croak "Illegal parameter ($key => $val)" unless exists $param{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 2 | $key = $param{$key}; | |||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||
| 148 | 2 | ▶ | $key eq "family" && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | $val = "\u\L$val"; | |||||||||||||||||||||||||||
| 150 | croak "Unknown font family ($val)" | ||||||||||||||||||||||||||||
| 151 | 0 | ▶ | unless exists $FontFamilies{$val}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | $self->{family} = $val; | |||||||||||||||||||||||||||
| 153 | 0 | last; | |||||||||||||||||||||||||||
| 154 | }; | ||||||||||||||||||||||||||||
| 155 | 2 | ▶ | $key eq "papersize" && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | $self->papersize($val) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | || croak sprintf "Unknown papersize '%s'.\nThe knowns are: %s.\nAborting", | ||||||||||||||||||||||||||||
| 158 | $val, | ||||||||||||||||||||||||||||
| 159 | join( ', ', sort keys %PaperSizes ); | ||||||||||||||||||||||||||||
| 160 | 0 | last; | |||||||||||||||||||||||||||
| 161 | }; | ||||||||||||||||||||||||||||
| 162 | 2 | $self->{$key} = lc $val; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub papersize { | ||||||||||||||||||||||||||
|
Subroutine
papersize: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 169 | 0 | my ( $self, $val ) = @_; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | $val = "\u\L$val"; | |||||||||||||||||||||||||||
| 172 | 0 | ▶ | my ( $width, $height ) = @{ $PaperSizes{$val} || return 0 }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$PaperSizes{$val} || (return 0)
MC/DC0%0/1
$PaperSizes{$val} || (return 0)
$PaperSizes{$val}
Truth table0%0/2
A
A= $PaperSizes{$val}
| |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return 0 unless defined $width; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | 0 | $self->{papersize} = $val; | |||||||||||||||||||||||||||
| 175 | 0 | $self->{paperwidth} = $width; | |||||||||||||||||||||||||||
| 176 | 0 | $self->{paperheight} = $height; | |||||||||||||||||||||||||||
| 177 | 0 | 1; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 181 | 823 | ▶ | sub fontsize { | ||||||||||||||||||||||||||
|
Subroutine
fontsize: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 182 | 823 | my $self = shift; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 823 | my $size = $self->{font_size}[-1]; | |||||||||||||||||||||||||||
| 185 | 823 | ▶ | $size = 8 if $size > 8; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 823 | ▶ | $size = 3 if $size < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 823 | $FontSizes[$size] * $self->{fontscale}; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | # Determine the current font and set font-related members. | ||||||||||||||||||||||||||||
| 191 | # If $plain_with_size is given (a number), use a plain font | ||||||||||||||||||||||||||||
| 192 | # of that size. Otherwise, use the font specified by the | ||||||||||||||||||||||||||||
| 193 | # HTML context. Returns the "font ID" of the current font. | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 196 | 823 | ▶ | sub setfont { | ||||||||||||||||||||||||||
|
Subroutine
setfont: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 197 | 823 | my ( $self, $plain_with_size ) = @_; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 823 | my $index = 0; | |||||||||||||||||||||||||||
| 200 | 823 | ▶ | my $family = $self->{family} || 'Times'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'family'} || 'Times'
MC/DC0%0/1
$self->{'family'} || 'Times'
$self->{'family'}
Truth table50%1/2
A
A= $self->{'family'}
| |||||||||||||||||||||||||||||
| 201 | 823 | my $size = $plain_with_size; | |||||||||||||||||||||||||||
| 202 | 823 | ▶ | unless ($plain_with_size) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | 817 | ▶ | $index |= BOLD if $self->{bold}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 817 | ▶ | $index |= ITALIC if $self->{italic} || $self->{underline}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"italic"} or $self->{"underline"}
MC/DC50%1/2
$self->{"italic"} or $self->{"underline"}
$self->{"italic"}
$self->{"underline"}
Truth table66%2/3
A or B
A= $self->{"italic"}B= $self->{"underline"}
| |||||||||||||||||||||||||||||
| 205 | 817 | ▶ | $family = 'Courier' if $self->{teletype}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 817 | $size = $self->fontsize; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | 823 | my $font = $FontFamilies{$family}[$index]; | |||||||||||||||||||||||||||
| 209 | 823 | my $font_with_size = "$font-$size"; | |||||||||||||||||||||||||||
| 210 | 823 | ▶ | if ( $self->{currentfont} eq $font_with_size ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 800 | return $self->{currentfontid}; | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | 23 | $self->{currentfont} = $font_with_size; | |||||||||||||||||||||||||||
| 214 | 23 | $self->{pointsize} = $size; | |||||||||||||||||||||||||||
| 215 | 23 | my $fontmod = "Font::Metrics::$font"; | |||||||||||||||||||||||||||
| 216 | 23 | $fontmod =~ s/-//g; | |||||||||||||||||||||||||||
| 217 | 23 | my $fontfile = $fontmod . ".pm"; | |||||||||||||||||||||||||||
| 218 | 23 | $fontfile =~ s,::,/,g; | |||||||||||||||||||||||||||
| 219 | 23 | require $fontfile; | |||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||
| 221 | ## no critic | ||||||||||||||||||||||||||||
| 222 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 223 | 23 | $self->{wx} = \@{"${fontmod}::wx"}; | |||||||||||||||||||||||||||
| 224 | ## use critic | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | 23 | ▶ | $font = $self->{fonts}{$font_with_size} || do { | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'fonts'}{$font_with_size} || do {
my $fontID = 'F' . ++$self->{'fno'};
$self->{'fonts'}{$font_with_size} = $fontID;
$fontID
}
MC/DC0%0/2
$self->{'fonts'}{$font_with_size} || do {
my $fontID = 'F' . ++$self->{'fno'};
$self->{'fonts'}{$font_with_size} = $fontID;
$fontID
}
$self->{'fonts'}{$font_with_size}
do {
my $fontID = 'F' . ++$self->{'fno'};
$self->{'fonts'}{$font_with_size} = $fontID;
$fontID
}
Truth table66%2/3
A || B
A= $self->{'fonts'}{$font_with_size}B= do {
my $fontID = 'F' . ++$self->{'fno'};
$self->{'fonts'}{$font_with_size} = $fontID;
$fontID
}
| |||||||||||||||||||||||||||||
| 227 | 17 | my $fontID = "F" . ++$self->{fno}; | |||||||||||||||||||||||||||
| 228 | 17 | $self->{fonts}{$font_with_size} = $fontID; | |||||||||||||||||||||||||||
| 229 | 17 | $fontID; | |||||||||||||||||||||||||||
| 230 | }; | ||||||||||||||||||||||||||||
| 231 | 23 | $self->{currentfontid} = $font; | |||||||||||||||||||||||||||
| 232 | 23 | return $font; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 236 | # Construct PostScript code for setting the current font according | ||||||||||||||||||||||||||||
| 237 | # to $fontid, or an empty string if no font change is needed. | ||||||||||||||||||||||||||||
| 238 | # Assumes the return string will always be output as PostScript if | ||||||||||||||||||||||||||||
| 239 | # nonempty, so that our notion of the current PostScript font | ||||||||||||||||||||||||||||
| 240 | # stays in sync with that of the PostScript interpreter. | ||||||||||||||||||||||||||||
| 241 | # | ||||||||||||||||||||||||||||
| 242 | 787 | ▶ | sub switchfont { | ||||||||||||||||||||||||||
|
Subroutine
switchfont: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 243 | 787 | my ( $self, $fontid ) = @_; | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 787 | ▶ | if ( $self->{psfontid} eq $fontid ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | 767 | return ""; | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | else { | ||||||||||||||||||||||||||||
| 249 | 20 | $self->{psfontid} = $fontid; | |||||||||||||||||||||||||||
| 250 | 20 | return "$fontid SF"; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 255 | # Like setfont + switchfont. | ||||||||||||||||||||||||||||
| 256 | 7 | ▶ | sub findfont { | ||||||||||||||||||||||||||
|
Subroutine
findfont: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 257 | 7 | my ( $self, $plain_with_size ) = @_; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 7 | return $self->switchfont( $self->setfont($plain_with_size) ); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 263 | 816 | ▶ | sub width { | ||||||||||||||||||||||||||
|
Subroutine
width: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 264 | 816 | my $self = shift; | |||||||||||||||||||||||||||
| 265 | 816 | my $str = shift; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 816 | my $w = 0; | |||||||||||||||||||||||||||
| 268 | 816 | my $wx = $self->{wx}; | |||||||||||||||||||||||||||
| 269 | 816 | my $sz = $self->{pointsize}; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # need to encode to same encoding as font before getting width | ||||||||||||||||||||||||||||
| 272 | 816 | for ( unpack( "C*", $self->encode_string($str) ) ) { | |||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | # if the character is outside the table, assume its m sized | ||||||||||||||||||||||||||||
| 275 | 2345 | ▶ | $w += ( ( $_ > $#{$wx} ) ? $wx->[ ord('m') ] : $wx->[$_] ) * $sz # unless $_ eq 0xAD; # optional hyphen | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | 816 | $w; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 281 | 6 | ▶ | sub begin { | ||||||||||||||||||||||||||
|
Subroutine
begin: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 282 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 6 | $self->SUPER::begin; | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | # Margins are in points | ||||||||||||||||||||||||||||
| 287 | 6 | ▶ | $self->{lm} = $self->{lmW} || $self->{mW}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'lmW'} || $self->{'mW'}
MC/DC0%0/2
$self->{'lmW'} || $self->{'mW'}
$self->{'lmW'}
$self->{'mW'}
Truth table66%2/3
A || B
A= $self->{'lmW'}B= $self->{'mW'}
| |||||||||||||||||||||||||||||
| 288 | 6 | ▶ | $self->{rm} = $self->{paperwidth} - ( $self->{rmW} || $self->{mW} ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'rmW'} || $self->{'mW'}
MC/DC0%0/2
$self->{'rmW'} || $self->{'mW'}
$self->{'rmW'}
$self->{'mW'}
Truth table66%2/3
A || B
A= $self->{'rmW'}B= $self->{'mW'}
| |||||||||||||||||||||||||||||
| 289 | 6 | ▶ | $self->{tm} = $self->{paperheight} - ( $self->{tmH} || $self->{mH} ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'tmH'} || $self->{'mH'}
MC/DC0%0/2
$self->{'tmH'} || $self->{'mH'}
$self->{'tmH'}
$self->{'mH'}
Truth table33%1/3
A || B
A= $self->{'tmH'}B= $self->{'mH'}
| |||||||||||||||||||||||||||||
| 290 | 6 | ▶ | $self->{bm} = $self->{bmH} || $self->{mH}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'bmH'} || $self->{'mH'}
MC/DC0%0/2
$self->{'bmH'} || $self->{'mH'}
$self->{'bmH'}
$self->{'mH'}
Truth table33%1/3
A || B
A= $self->{'bmH'}B= $self->{'mH'}
| |||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | $self->{'orig_margins'} = # used only by the debug-mode print-area marker | ||||||||||||||||||||||||||||
| 293 | 6 | [ map { sprintf "%.1f", $_ } @{$self}{qw(lm bm rm tm)} ]; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | # Font setup | ||||||||||||||||||||||||||||
| 296 | 6 | $self->{fno} = 0; | |||||||||||||||||||||||||||
| 297 | 6 | $self->{fonts} = {}; | |||||||||||||||||||||||||||
| 298 | 6 | $self->{en} = 0.55 * $self->fontsize(3); | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | # Initial position | ||||||||||||||||||||||||||||
| 301 | 6 | $self->{xpos} = $self->{lm}; # top of the current line | |||||||||||||||||||||||||||
| 302 | 6 | $self->{ypos} = $self->{tm}; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 6 | $self->{pageno} = 1; | |||||||||||||||||||||||||||
| 305 | 6 | $self->{visible_page_number} = $self->{startpage}; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 6 | $self->{line} = ""; | |||||||||||||||||||||||||||
| 308 | 6 | $self->{showstring} = ""; | |||||||||||||||||||||||||||
| 309 | 6 | $self->{currentfont} = ""; | |||||||||||||||||||||||||||
| 310 | 6 | $self->{prev_currentfont} = ""; | |||||||||||||||||||||||||||
| 311 | 6 | $self->{largest_pointsize} = 0; | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 6 | $self->newpage; | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 317 | 6 | ▶ | sub end { | ||||||||||||||||||||||||||
|
Subroutine
end: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 318 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 6 | $self->showline; | |||||||||||||||||||||||||||
| 321 | 6 | ▶ | $self->endpage if $self->{'out'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 322 | 6 | my $pages = $self->{pageno} - 1; | |||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | 6 | my @prolog = (); | |||||||||||||||||||||||||||
| 325 | 6 | push( @prolog, "%!PS-Adobe-3.0\n" ); | |||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | #push(@prolog,"%%Title: No title\n"); # should look for the <title> element | ||||||||||||||||||||||||||||
| 328 | 6 | push( @prolog, "%%Creator: " . $self->version_tag . "\n" ); | |||||||||||||||||||||||||||
| 329 | 6 | push( @prolog, "%%CreationDate: " . localtime() . "\n" ); | |||||||||||||||||||||||||||
| 330 | 6 | push( @prolog, "%%Pages: $pages\n" ); | |||||||||||||||||||||||||||
| 331 | 6 | push( @prolog, "%%PageOrder: Ascend\n" ); | |||||||||||||||||||||||||||
| 332 | 6 | push( @prolog, "%%Orientation: Portrait\n" ); | |||||||||||||||||||||||||||
| 333 | 6 | my ( $pw, $ph ) = map { int($_); } @{$self}{qw(paperwidth paperheight)}; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 6 | push( @prolog, "%%DocumentMedia: Plain $pw $ph 0 white ()\n" ); | |||||||||||||||||||||||||||
| 336 | 6 | push( @prolog, "%%DocumentNeededResources: \n" ); | |||||||||||||||||||||||||||
| 337 | 6 | my %seenfont; | |||||||||||||||||||||||||||
| 338 | 6 | for my $full ( sort keys %{ $self->{fonts} } ) { | |||||||||||||||||||||||||||
| 339 | 17 | $full =~ s/-\d+$//; | |||||||||||||||||||||||||||
| 340 | 17 | ▶ | next if $seenfont{$full}++; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 9 | push( @prolog, "%%+ font $full\n" ); | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | 6 | push( @prolog, "%%DocumentSuppliedResources: procset newencode 1.0 0\n" ); | |||||||||||||||||||||||||||
| 344 | 6 | push( @prolog, "%%+ encoding ISOLatin1Encoding\n" ); | |||||||||||||||||||||||||||
| 345 | 6 | push( @prolog, "%%EndComments\n" ); | |||||||||||||||||||||||||||
| 346 | 6 | push( @prolog, <<'EOT'); | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | %%BeginProlog | ||||||||||||||||||||||||||||
| 349 | /S/show load def | ||||||||||||||||||||||||||||
| 350 | /M/moveto load def | ||||||||||||||||||||||||||||
| 351 | /SF/setfont load def | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | %%BeginResource: encoding ISOLatin1Encoding | ||||||||||||||||||||||||||||
| 354 | systemdict /ISOLatin1Encoding known not { | ||||||||||||||||||||||||||||
| 355 | /ISOLatin1Encoding [ | ||||||||||||||||||||||||||||
| 356 | /space /space /space /space /space /space /space /space | ||||||||||||||||||||||||||||
| 357 | /space /space /space /space /space /space /space /space | ||||||||||||||||||||||||||||
| 358 | /space /space /space /space /space /space /space /space | ||||||||||||||||||||||||||||
| 359 | /space /space /space /space /space /space /space /space | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | /space /exclam /quotedbl /numbersign /dollar /percent /ampersand | ||||||||||||||||||||||||||||
| 362 | /quoteright | ||||||||||||||||||||||||||||
| 363 | /parenleft /parenright /asterisk /plus /comma /minus /period /slash | ||||||||||||||||||||||||||||
| 364 | /zero /one /two /three /four /five /six /seven | ||||||||||||||||||||||||||||
| 365 | /eight /nine /colon /semicolon /less /equal /greater /question | ||||||||||||||||||||||||||||
| 366 | /at /A /B /C /D /E /F /G | ||||||||||||||||||||||||||||
| 367 | /H /I /J /K /L /M /N /O | ||||||||||||||||||||||||||||
| 368 | /P /Q /R /S /T /U /V /W | ||||||||||||||||||||||||||||
| 369 | /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore | ||||||||||||||||||||||||||||
| 370 | /quoteleft /a /b /c /d /e /f /g | ||||||||||||||||||||||||||||
| 371 | /h /i /j /k /l /m /n /o | ||||||||||||||||||||||||||||
| 372 | /p /q /r /s /t /u /v /w | ||||||||||||||||||||||||||||
| 373 | /x /y /z /braceleft /bar /braceright /asciitilde /space | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | /space /space /space /space /space /space /space /space | ||||||||||||||||||||||||||||
| 376 | /space /space /space /space /space /space /space /space | ||||||||||||||||||||||||||||
| 377 | /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent | ||||||||||||||||||||||||||||
| 378 | /dieresis /space /ring /cedilla /space /hungarumlaut /ogonek /caron | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | /space /exclamdown /cent /sterling /currency /yen /brokenbar /section | ||||||||||||||||||||||||||||
| 381 | /dieresis /copyright /ordfeminine /guillemotleft /logicalnot /hyphen | ||||||||||||||||||||||||||||
| 382 | /registered /macron | ||||||||||||||||||||||||||||
| 383 | /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph | ||||||||||||||||||||||||||||
| 384 | /periodcentered | ||||||||||||||||||||||||||||
| 385 | /cedillar /onesuperior /ordmasculine /guillemotright /onequarter | ||||||||||||||||||||||||||||
| 386 | /onehalf /threequarters /questiondown | ||||||||||||||||||||||||||||
| 387 | /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla | ||||||||||||||||||||||||||||
| 388 | /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex | ||||||||||||||||||||||||||||
| 389 | /Idieresis | ||||||||||||||||||||||||||||
| 390 | /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply | ||||||||||||||||||||||||||||
| 391 | /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn | ||||||||||||||||||||||||||||
| 392 | /germandbls | ||||||||||||||||||||||||||||
| 393 | /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla | ||||||||||||||||||||||||||||
| 394 | /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex | ||||||||||||||||||||||||||||
| 395 | /idieresis | ||||||||||||||||||||||||||||
| 396 | /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide | ||||||||||||||||||||||||||||
| 397 | /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn | ||||||||||||||||||||||||||||
| 398 | /ydieresis | ||||||||||||||||||||||||||||
| 399 | ] def | ||||||||||||||||||||||||||||
| 400 | } if | ||||||||||||||||||||||||||||
| 401 | %%EndResource | ||||||||||||||||||||||||||||
| 402 | %%BeginResource: procset newencode 1.0 0 | ||||||||||||||||||||||||||||
| 403 | /NE { %def | ||||||||||||||||||||||||||||
| 404 | findfont begin | ||||||||||||||||||||||||||||
| 405 | currentdict dup length dict begin | ||||||||||||||||||||||||||||
| 406 | { %forall | ||||||||||||||||||||||||||||
| 407 | 1 index/FID ne {def} {pop pop} ifelse | ||||||||||||||||||||||||||||
| 408 | } forall | ||||||||||||||||||||||||||||
| 409 | /FontName exch def | ||||||||||||||||||||||||||||
| 410 | /Encoding exch def | ||||||||||||||||||||||||||||
| 411 | currentdict dup | ||||||||||||||||||||||||||||
| 412 | end | ||||||||||||||||||||||||||||
| 413 | end | ||||||||||||||||||||||||||||
| 414 | /FontName get exch definefont pop | ||||||||||||||||||||||||||||
| 415 | } bind def | ||||||||||||||||||||||||||||
| 416 | %%EndResource | ||||||||||||||||||||||||||||
| 417 | %%EndProlog | ||||||||||||||||||||||||||||
| 418 | EOT | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 6 | push( @prolog, "\n%%BeginSetup\n" ); | |||||||||||||||||||||||||||
| 421 | 6 | for my $full ( sort keys %{ $self->{fonts} } ) { | |||||||||||||||||||||||||||
| 422 | 17 | my $short = $self->{fonts}{$full}; | |||||||||||||||||||||||||||
| 423 | 17 | $full =~ s/-(\d+)$//; | |||||||||||||||||||||||||||
| 424 | 17 | my $size = $1; | |||||||||||||||||||||||||||
| 425 | 17 | push( @prolog, "ISOLatin1Encoding/$full-ISO/$full NE\n" ); | |||||||||||||||||||||||||||
| 426 | 17 | push( @prolog, "/$short/$full-ISO findfont $size scalefont def\n" ); | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | 6 | push( @prolog, "%%EndSetup\n" ); | |||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | $self->collect("\n%%Trailer\n%%EOF\n") | ||||||||||||||||||||||||||||
| 431 | 6 | ▶ | unless $self->{'no_trailer'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | 6 | unshift( @{ $self->{output} }, @prolog ) | |||||||||||||||||||||||||||
| 434 | 6 | ▶ | unless $self->{'no_prolog'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 438 | 2 | ▶ | sub header_start { | ||||||||||||||||||||||||||
|
Subroutine
header_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 439 | 2 | my ( $self, $level ) = @_; | |||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | # If we are close enough to be bottom of the page, start a new page | ||||||||||||||||||||||||||||
| 442 | # instead of this: | ||||||||||||||||||||||||||||
| 443 | ### Heading of level: $level | ||||||||||||||||||||||||||||
| 444 | 2 | $self->vspace( 1 + ( 6 - $level ) * 0.4 ); | |||||||||||||||||||||||||||
| 445 | 2 | $self->{bold}++; | |||||||||||||||||||||||||||
| 446 | 2 | push( @{ $self->{font_size} }, 8 - $level ); | |||||||||||||||||||||||||||
| 447 | 2 | 1; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 451 | 2 | ▶ | sub header_end { | ||||||||||||||||||||||||||
|
Subroutine
header_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 452 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | 2 | $self->vspace(1); | |||||||||||||||||||||||||||
| 455 | 2 | $self->{bold}--; | |||||||||||||||||||||||||||
| 456 | 2 | pop( @{ $self->{font_size} } ); | |||||||||||||||||||||||||||
| 457 | 2 | 1; | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 461 | 1 | ▶ | sub hr_start { | ||||||||||||||||||||||||||
|
Subroutine
hr_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 462 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | ### Making an HR... | ||||||||||||||||||||||||||||
| 465 | 1 | $self->showline; | |||||||||||||||||||||||||||
| 466 | 1 | $self->vspace(0.5); | |||||||||||||||||||||||||||
| 467 | 1 | $self->skip_vspace; | |||||||||||||||||||||||||||
| 468 | 1 | my $lm = $self->{lm}; | |||||||||||||||||||||||||||
| 469 | 1 | my $rm = $self->{rm}; | |||||||||||||||||||||||||||
| 470 | 1 | my $y = $self->{ypos}; | |||||||||||||||||||||||||||
| 471 | 1 | $self->collect( sprintf "newpath %.1f %.1f M %.1f %.1f lineto stroke\n", $lm, $y, $rm, $y ); | |||||||||||||||||||||||||||
| 472 | 1 | $self->vspace(0.5); | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 476 | 409 | ▶ | sub skip_vspace { | ||||||||||||||||||||||||||
|
Subroutine
skip_vspace: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 477 | 409 | my $self = shift; | |||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | ### Skipping some amount of vspace... | ||||||||||||||||||||||||||||
| 480 | 409 | ▶ | if ( defined $self->{vspace} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 481 | 20 | $self->showline; | |||||||||||||||||||||||||||
| 482 | 20 | ▶ | if ( $self->{'out'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | 19 | $self->{ypos} -= $self->{vspace} * 10 * $self->{fontscale}; | |||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 19 | ▶ | if ( $self->{ypos} < $self->{bm} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 486 | ### vspace skip forced new page... | ||||||||||||||||||||||||||||
| 487 | 0 | $self->newpage; | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | else { | ||||||||||||||||||||||||||||
| 490 | ### Skipped vspace making y: $self->{'ypos'}, | ||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | else { | ||||||||||||||||||||||||||||
| 494 | ### Not skipping vspace as out is false: $self->{ypos} | ||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||
| 496 | 20 | $self->{xpos} = $self->{lm}; | |||||||||||||||||||||||||||
| 497 | 20 | $self->{vspace} = undef; | |||||||||||||||||||||||||||
| 498 | 20 | $self->{hspace} = undef; | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | else { | ||||||||||||||||||||||||||||
| 501 | ### No vspace to skip... | ||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 409 | return; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 508 | 71 | ▶ | sub show { | ||||||||||||||||||||||||||
|
Subroutine
show: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 509 | 71 | my $self = shift; | |||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 71 | my $str = $self->{showstring}; | |||||||||||||||||||||||||||
| 512 | 71 | $str =~ tr/\x01//d; | |||||||||||||||||||||||||||
| 513 | 71 | ▶ | return unless length $str; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | # must escape parentheses and backslash | ||||||||||||||||||||||||||||
| 516 | 38 | $str =~ s/([\(\)\\])/\\$1/g; | |||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | # encode output to latin1 when pushing it out | ||||||||||||||||||||||||||||
| 519 | 38 | $self->{line} .= "(" . $self->encode_string($str) . ")S\n"; | |||||||||||||||||||||||||||
| 520 | 38 | $self->{showstring} = ""; | |||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 524 | 57 | ▶ | sub showline { | ||||||||||||||||||||||||||
|
Subroutine
showline: called CC=8 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 525 | 57 | my $self = shift; | |||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 57 | $self->show; | |||||||||||||||||||||||||||
| 528 | 57 | my $line = $self->{line}; | |||||||||||||||||||||||||||
| 529 | 57 | ▶ | unless ( length $line ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 530 | ### Showline is a no-op because line buffer is empty... | ||||||||||||||||||||||||||||
| 531 | 19 | return; | |||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | ### Showline emitting: $line | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | 38 | ▶ | $self->{ypos} -= $self->{largest_pointsize} || $self->{pointsize}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'largest_pointsize'} || $self->{'pointsize'}
MC/DC0%0/2
$self->{'largest_pointsize'} || $self->{'pointsize'}
$self->{'largest_pointsize'}
$self->{'pointsize'}
Truth table66%2/3
A || B
A= $self->{'largest_pointsize'}B= $self->{'pointsize'}
| |||||||||||||||||||||||||||||
| 537 | 38 | ▶ | if ( $self->{ypos} < $self->{bm} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 538 | ### Showline forcing new page... | ||||||||||||||||||||||||||||
| 539 | 0 | $self->newpage; | |||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | # newpage might alter currentfont! | ||||||||||||||||||||||||||||
| 542 | ### Showline sets vspace: $self->{vspace} || 0 | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 0 | $self->{ypos} -= $self->{pointsize}; | |||||||||||||||||||||||||||
| 545 | #### Showline/Newpage x: $self->{xpos} | ||||||||||||||||||||||||||||
| 546 | #### Showline/Newpage y: $self->{ypos} | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | # must set current font again | ||||||||||||||||||||||||||||
| 549 | 0 | my $font = $self->{prev_currentfont}; | |||||||||||||||||||||||||||
| 550 | 0 | ▶ | if ($font) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | 0 | $self->collect("$self->{fonts}{$font} SF\n\n"); | |||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | ### End of doing newpage... | ||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | 38 | my $lm = $self->{lm}; | |||||||||||||||||||||||||||
| 558 | 38 | my $x = $lm; | |||||||||||||||||||||||||||
| 559 | 38 | ▶ | if ( $self->{center} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | # Unfortunately, the center attribute is gone when we get here, | ||||||||||||||||||||||||||||
| 562 | # so this code is never activated | ||||||||||||||||||||||||||||
| 563 | 0 | my $linewidth = $self->{xpos} - $lm; | |||||||||||||||||||||||||||
| 564 | 0 | $x += ( $self->{rm} - $lm - $linewidth ) / 2; | |||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | 38 | $self->collect( sprintf "%.1f %.1f M\n", $x, $self->{ypos} ); # moveto | |||||||||||||||||||||||||||
| 568 | 38 | $line =~ s/\s\)S$/)S/; # many lines will end uselessly with space | |||||||||||||||||||||||||||
| 569 | 38 | $self->collect($line); | |||||||||||||||||||||||||||
| 570 | 38 | $self->{'out'}++; | |||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | 38 | ▶ | if ( $self->{bullet} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | # Putting this behind the first line of the list item | ||||||||||||||||||||||||||||
| 575 | # makes it more likely that we get the right font. We should | ||||||||||||||||||||||||||||
| 576 | # really set the font that we want to use. | ||||||||||||||||||||||||||||
| 577 | 4 | my $bullet = $self->{bullet}; | |||||||||||||||||||||||||||
| 578 | 4 | ▶ | if ( $bullet eq '*' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | # There is no character that is really suitable. Let's make | ||||||||||||||||||||||||||||
| 581 | # a medium-sized filled circle ourself. | ||||||||||||||||||||||||||||
| 582 | 2 | my $radius = $self->{pointsize} / 8; | |||||||||||||||||||||||||||
| 583 | ### Adding code for a '*' bullet for that line... | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | $self->collect( | ||||||||||||||||||||||||||||
| 586 | sprintf "newpath %.1f %.1f %.1f 0 360 arc fill\n", | ||||||||||||||||||||||||||||
| 587 | $self->{bullet_pos} + $radius, | ||||||||||||||||||||||||||||
| 588 | 2 | $self->{ypos} + $radius * 2, $radius, | |||||||||||||||||||||||||||
| 589 | ); | ||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||
| 591 | else { | ||||||||||||||||||||||||||||
| 592 | ### Adding code for other bullet for that line... | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | $self->collect( | ||||||||||||||||||||||||||||
| 595 | sprintf "%.1f (%s) stringwidth pop sub %.1f add %.1f M\n", # moveto | ||||||||||||||||||||||||||||
| 596 | $self->{bullet_pos}, | ||||||||||||||||||||||||||||
| 597 | $bullet, | ||||||||||||||||||||||||||||
| 598 | $self->{pointsize} * 0.62, | ||||||||||||||||||||||||||||
| 599 | $self->{ypos}, | ||||||||||||||||||||||||||||
| 600 | 2 | ); | |||||||||||||||||||||||||||
| 601 | 2 | $self->collect("($bullet)S\n"); | |||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||
| 603 | 4 | $self->{bullet} = ''; | |||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | 38 | $self->{prev_currentfont} = $self->{currentfont}; | |||||||||||||||||||||||||||
| 608 | 38 | $self->{largest_pointsize} = 0; | |||||||||||||||||||||||||||
| 609 | 38 | $self->{line} = ""; | |||||||||||||||||||||||||||
| 610 | 38 | $self->{xpos} = $lm; | |||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | # Additional linespacing | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | 38 | $self->{ypos} -= $self->{leading} * $self->{pointsize}; | |||||||||||||||||||||||||||
| 615 | #### Showline/end x: $self->{xpos} | ||||||||||||||||||||||||||||
| 616 | #### Showline/end y: $self->{ypos} | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | 38 | return; | |||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 622 | 6 | ▶ | sub endpage { | ||||||||||||||||||||||||||
|
Subroutine
endpage: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 623 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | ### End page: $self->{pageno} | ||||||||||||||||||||||||||||
| 626 | # End previous page | ||||||||||||||||||||||||||||
| 627 | 6 | $self->collect("showpage\n"); | |||||||||||||||||||||||||||
| 628 | 6 | $self->{visible_page_number}++; | |||||||||||||||||||||||||||
| 629 | 6 | $self->{pageno}++; | |||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 633 | 6 | ▶ | sub newpage { | ||||||||||||||||||||||||||
|
Subroutine
newpage: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 634 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | 6 | local $self->{'pointsize'} = $self->{'pointsize'}; | |||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | # That's needed for protecting against one bit of the | ||||||||||||||||||||||||||||
| 639 | # potential side-effects from page-numbering code | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | 6 | ▶ | if ( $self->{'out'} ) { # whether we've sent anything to the current page so far. | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 642 | ### Newpage calls endpage... | ||||||||||||||||||||||||||||
| 643 | 0 | $self->endpage; | |||||||||||||||||||||||||||
| 644 | 0 | $self->collect( sprintf "%% %s has sent %s write-events to the above page.\n", ref($self), $self->{'out'}, ); | |||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | 6 | $self->{'out'} = 0; | |||||||||||||||||||||||||||
| 648 | 6 | my $pageno = $self->{pageno}; | |||||||||||||||||||||||||||
| 649 | 6 | my $visible_page_number = $self->{visible_page_number}; | |||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | 6 | $self->collect("\n%%Page: $pageno $pageno\n"); | |||||||||||||||||||||||||||
| 652 | ### Starting page: $pageno | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | # Print page number | ||||||||||||||||||||||||||||
| 655 | 6 | ▶ | if ( $self->{printpageno} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 656 | ### Printing page number: $visible_page_number | ||||||||||||||||||||||||||||
| 657 | 6 | $self->collect("%% Title and pageno\n"); | |||||||||||||||||||||||||||
| 658 | 6 | my $f = $self->findfont(8); | |||||||||||||||||||||||||||
| 659 | 6 | ▶ | $self->collect("$f\n") if $f; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 660 | 6 | my $x = $self->{paperwidth}; | |||||||||||||||||||||||||||
| 661 | 6 | ▶ | if ($x) { $x -= 30; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 662 | 0 | else { $x = 30; } | |||||||||||||||||||||||||||
| 663 | 6 | $self->collect( sprintf "%.1f 30.0 M($visible_page_number)S\n", $x ); | |||||||||||||||||||||||||||
| 664 | 6 | $x = $self->{lm}; | |||||||||||||||||||||||||||
| 665 | 6 | $self->{title} =~ tr/\x01//d; | |||||||||||||||||||||||||||
| 666 | 6 | $self->collect( sprintf "%.1f 30.0 M($self->{title})S\n", $x ); | |||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||
| 668 | else { | ||||||||||||||||||||||||||||
| 669 | ### Pointedly not printing page number... | ||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||
| 671 | 6 | $self->collect("\n"); | |||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | 6 | $self->{xpos} = $self->{lm}; | |||||||||||||||||||||||||||
| 674 | 6 | $self->{ypos} = $self->{tm}; | |||||||||||||||||||||||||||
| 675 | #### Newpage/end x: $self->{xpos} | ||||||||||||||||||||||||||||
| 676 | #### Newpage/end y: $self->{ypos} | ||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 680 | 854 | ▶ | sub encode_string { # converts string into latin1 charset | ||||||||||||||||||||||||||
|
Subroutine
encode_string: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 681 | 854 | my ( $self, $str ) = @_; | |||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | # the string from the parser is normally unicode, and may contain | ||||||||||||||||||||||||||||
| 684 | # some punctuation characters in the 'General Punctuation' block | ||||||||||||||||||||||||||||
| 685 | # which can be expressed in latin1, but Encode module fails on them | ||||||||||||||||||||||||||||
| 686 | # so we will manually hack these... | ||||||||||||||||||||||||||||
| 687 | # Theres no usable latin1 for the double quote chars so map to " | ||||||||||||||||||||||||||||
| 688 | 854 | ▶ | if ( utf8::is_utf8($str) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 689 | 64 | $str =~ tr/\x{2018}\x{2019}\x{201A}\x{201C}\x{201D}\x{201F}\x{2033}\x{2036}/`',"""""/; | |||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 854 | return $self->{encoder}->encode($str); | |||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 696 | 823 | ▶ | sub out { # Output a word | ||||||||||||||||||||||||||
|
Subroutine
out: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 697 | 823 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||
| 699 | 823 | $text =~ tr/\xA0\xAD/ /d; | |||||||||||||||||||||||||||
| 700 | ### Trapping new word: $text | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | 823 | ▶ | if ( $self->{collectingTheTitle} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | # Both collect and print the title | ||||||||||||||||||||||||||||
| 705 | 7 | $text =~ s/([\(\)\\])/\\$1/g; # Escape parens and the backslash | |||||||||||||||||||||||||||
| 706 | 7 | $self->{title} .= $text; | |||||||||||||||||||||||||||
| 707 | 7 | return; | |||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | 816 | my $fontid = $self->setfont(); | |||||||||||||||||||||||||||
| 711 | 816 | my $w = $self->width($text); | |||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | 816 | ▶ | if ( $text =~ /^\s*$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 714 | 409 | $self->{hspace} = [ " ", $fontid, $w ]; | |||||||||||||||||||||||||||
| 715 | 409 | return; | |||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | 407 | $self->skip_vspace; | |||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | # determine spacing / line breaks needed before text | ||||||||||||||||||||||||||||
| 721 | 407 | ▶ | if ( $self->{hspace} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 722 | 384 | my ( $stext, $sfont, $swidth ) = @{ $self->{hspace} }; | |||||||||||||||||||||||||||
| 723 | 384 | ▶ | if ( $self->{xpos} + $swidth + $w > $self->{rm} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | # line break | ||||||||||||||||||||||||||||
| 726 | 11 | $self->showline; | |||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||
| 728 | else { | ||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | # no line break; output a space | ||||||||||||||||||||||||||||
| 731 | 373 | $self->show_with_font( $stext, $sfont, $swidth ); | |||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||
| 733 | 384 | $self->{hspace} = undef; | |||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||
| 736 | # output the text | ||||||||||||||||||||||||||||
| 737 | 407 | $self->show_with_font( $text, $fontid, $w ); | |||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 741 | 780 | ▶ | sub show_with_font { | ||||||||||||||||||||||||||
|
Subroutine
show_with_font: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 742 | 780 | my ( $self, $text, $fontid, $w ) = @_; | |||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | 780 | my $fontps = $self->switchfont($fontid); | |||||||||||||||||||||||||||
| 745 | 780 | ▶ | if ( length $fontps ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 746 | 13 | $self->show; | |||||||||||||||||||||||||||
| 747 | 13 | $self->{line} .= "$fontps\n"; | |||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||
| 750 | 780 | $self->{xpos} += $w; | |||||||||||||||||||||||||||
| 751 | 780 | $self->{showstring} .= $text; | |||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | #### Append to string buffer: $text | ||||||||||||||||||||||||||||
| 754 | #### with font: $fontid | ||||||||||||||||||||||||||||
| 755 | #### with xpos: $self->{xpos} | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | $self->{largest_pointsize} = $self->{pointsize} | ||||||||||||||||||||||||||||
| 758 | 780 | ▶ | if $self->{largest_pointsize} < $self->{pointsize}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 759 | 780 | $self->{'out'}++; | |||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||
| 762 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 763 | 1 | ▶ | sub pre_out { | ||||||||||||||||||||||||||
|
Subroutine
pre_out: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 764 | 1 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||
| 766 | 1 | $self->skip_vspace; | |||||||||||||||||||||||||||
| 767 | 1 | $self->tt_start; | |||||||||||||||||||||||||||
| 768 | 1 | my $font = $self->findfont(); | |||||||||||||||||||||||||||
| 769 | 1 | ▶ | if ( length $font ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 770 | 1 | $self->show; | |||||||||||||||||||||||||||
| 771 | 1 | $self->{line} .= "$font\n"; | |||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||
| 773 | 1 | ▶ | while ( $text =~ s/(.*)\n// ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 774 | 3 | $self->{'out'}++; | |||||||||||||||||||||||||||
| 775 | 3 | $self->{showstring} .= $1; | |||||||||||||||||||||||||||
| 776 | 3 | $self->showline; | |||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||
| 778 | 1 | $self->{showstring} .= $text; | |||||||||||||||||||||||||||
| 779 | 1 | $self->tt_end; | |||||||||||||||||||||||||||
| 780 | 1 | 1; | |||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||
| 783 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 784 | 4 | ▶ | sub bullet { | ||||||||||||||||||||||||||
|
Subroutine
bullet: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 785 | 4 | my ( $self, $bullet ) = @_; | |||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | 4 | $self->{bullet} = $bullet; | |||||||||||||||||||||||||||
| 788 | 4 | $self->{bullet_pos} = $self->{lm}; | |||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||
| 791 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 792 | 14 | ▶ | sub adjust_lm { | ||||||||||||||||||||||||||
|
Subroutine
adjust_lm: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 793 | 14 | my $self = shift; | |||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||
| 795 | 14 | $self->showline; | |||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | 14 | $self->{lm} += $_[0] * $self->{en}; | |||||||||||||||||||||||||||
| 798 | 14 | 1; | |||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 802 | 2 | ▶ | sub adjust_rm { | ||||||||||||||||||||||||||
|
Subroutine
adjust_rm: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 803 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||
| 805 | 2 | $self->showline; | |||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | 2 | $self->{rm} += $_[0] * $self->{en}; | |||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 811 | 6 | ▶ | sub head_start { 1; } | ||||||||||||||||||||||||||
|
Subroutine
head_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 812 | 6 | ▶ | sub head_end { 1; } | ||||||||||||||||||||||||||
|
Subroutine
head_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | 1 | ▶ | sub title_start { | ||||||||||||||||||||||||||
|
Subroutine
title_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 815 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||
| 817 | 1 | $self->{collectingTheTitle} = 1; | |||||||||||||||||||||||||||
| 818 | 1 | 1; | |||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | 1 | ▶ | sub title_end { | ||||||||||||||||||||||||||
|
Subroutine
title_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 822 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | 1 | $self->{collectingTheTitle} = 0; | |||||||||||||||||||||||||||
| 825 | 1 | 1; | |||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||
| 828 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 829 | 3 | my ( $counter, $last_state_filename ); | |||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||
| 831 | # For use in circumstances of total desperation: | ||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | 0 | ▶ | sub dump_state { | ||||||||||||||||||||||||||
|
Subroutine
dump_state: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 834 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 835 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | 0 | ++$counter; | |||||||||||||||||||||||||||
| 838 | 0 | my $filename = sprintf( "state%04d.txt", $counter ); | |||||||||||||||||||||||||||
| 839 | 0 | ▶ | my $state = IO::File->new( $filename, 'w' ) or die "Can't write-open $filename: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 840 | 0 | $state->printf( "%s line %s\n", ( caller(1) )[ 3, 2 ] ); | |||||||||||||||||||||||||||
| 841 | { | ||||||||||||||||||||||||||||
| 842 | 0 | local ( $self->{'wx'} ) = '<SUPPRESSED>'; | |||||||||||||||||||||||||||
| 843 | 0 | local ( $self->{'output'} ) = '<SUPPRESSED>'; | |||||||||||||||||||||||||||
| 844 | 0 | $state->print( Data::Dumper::Dumper($self) ); | |||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||
| 846 | 0 | $state->close; | |||||||||||||||||||||||||||
| 847 | 0 | sleep 0; | |||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||
| 849 | 0 | ▶ | if ($last_state_filename) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 850 | 0 | system("perl -S diff.bat $last_state_filename $filename > $filename.diff"); | |||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | 0 | $last_state_filename = $filename; | |||||||||||||||||||||||||||
| 854 | 0 | return 1; | |||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||
| 857 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||
| 860 | 3 | 1; | |||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||
| 862 | __END__ | ||||||||||||||||||||||||||||