| 1 | |||||||||||||||||||||||||||||||||||||||||||
| 2 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | Font::TFM -- read information from TeX font metric files | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | package Font::TFM; | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use vars qw( $VERSION $DEBUG $TEXFONTSDIR $TEXFONTSUSELS | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $LSFILENAME $MULTIPLY $errstr ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # ################ | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # Global variables | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | $errstr = ''; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 53 | ▶ | sub DEBUG () { $DEBUG; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEBUG: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | sub Error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Error: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | $errstr = join '', @_; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | print STDERR @_, "\n" if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | $TEXFONTSDIR = '.'; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | $TEXFONTSUSELS = 1; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | $LSFILENAME = "ls-R"; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | $MULTIPLY = 65536; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # ##################### | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # Load new font at size | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub new_at { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_at: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my ($class, $fontname, $size) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | new($class, 'name' => $fontname, 'at' => $size); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | # ######################## | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # Load new font with scale | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=29 SCAR=39.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | my %opts = (); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | if (@_ > 2 or (@_ == 2 and $_[1] !~ /^(\d*\.)?\d+$/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@_ > 2 or @_ == 2 and not $_[1] =~ /^(\d*\.)?\d+$/
@_ == 2 and not $_[1] =~ /^(\d*\.)?\d+$/
MC/DC33%1/3
@_ > 2 or @_ == 2 and not $_[1] =~ /^(\d*\.)?\d+$/
@_ > 2
@_ == 2
not $_[1] =~ /^(\d*\.)?\d+$/
Truth table50%2/4
A or B and not(C)
A= @_ > 2B= @_ == 2C= not $_[1] =~ /^(\d*\.)?\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | if (@_ % 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $opts{name} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | %opts = @_; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | @opts{'name', 'scale'} = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # make the object | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | my ($file_handle); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | $file_handle = $self->open_tfm(%opts); | |||||||||||||||||||||||||||||||||||||||||
| 60 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | Error($@); return; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # read header | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | my $buffer = ''; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | if (read($file_handle, $buffer, 24) != 24) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | Error("Error reading TFM header: $!"); return; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # get 12 fields of the header | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | @{$self}{ qw(length headerlength smallest largest numwidth | |||||||||||||||||||||||||||||||||||||||||
| 73 | numheight numdepth numic numligkern numkern numext numparam) } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | = unpack "n12", $buffer; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | $self->{numofchars} = $self->{largest} - $self->{smallest} + 1; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | $self->{'length'} = $self->{'length'} * 4 - 24; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | $self->{headerlength} *= 4; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | # read rest of the file | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 5 | ▶ | if (read($file_handle, $buffer, $self->{'length'}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | != $self->{'length'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | Error("Error reading body: $!"); return; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | close $file_handle; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | my $headerrestlength = $self->{headerlength} - 18 * 4; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | my ($face, $headerrest, @charinfo, @width, @height, @depth, | |||||||||||||||||||||||||||||||||||||||||
| 89 | @italic, @ligkern, @kern, @exten); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | # split the file into various arrays | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | (@{$self}{ qw(checksum designsize codingschemestringlength | |||||||||||||||||||||||||||||||||||||||||
| 93 | codingscheme familystringlength family sevenbitsafe ) }, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | undef, undef, $face, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | $headerrest, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | @charinfo[0 .. $self->{numofchars} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 97 | @width[0 .. $self->{numwidth} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 98 | @height[0 .. $self->{numheight} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 99 | @depth[0 .. $self->{numdepth} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 100 | @italic[0 .. $self->{numic} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 101 | @ligkern[0 .. $self->{numligkern} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 102 | @kern[0 .. $self->{numkern} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 103 | @exten[0 .. $self->{numext} - 1], | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | @{$self->{param}}[1 .. $self->{numparam}], | |||||||||||||||||||||||||||||||||||||||||
| 105 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 106 | = unpack "NNCA39CA19C4a$headerrestlength" . | ||||||||||||||||||||||||||||||||||||||||||
| 107 | "a4" x $self->{numofchars} . | ||||||||||||||||||||||||||||||||||||||||||
| 108 | "N$self->{numwidth}N$self->{numheight}N$self->{numdepth}N$self->{numic}" . | ||||||||||||||||||||||||||||||||||||||||||
| 109 | "a4" x $self->{numligkern} . | ||||||||||||||||||||||||||||||||||||||||||
| 110 | "N$self->{numkern}" . | ||||||||||||||||||||||||||||||||||||||||||
| 111 | "a4" x $self->{numext} . | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 5 | "N$self->{numparam}", $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 113 | # the unpack above does all the work, isn't it neat? | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | $self->{designsize} = getfixword($self->{designsize}); | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | my $fontsize = $self->{designsize}; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 5 | ▶ | if (defined $opts{at}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $fontsize = $opts{at}; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } elsif (defined $opts{scale}) { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $fontsize *= $opts{scale}; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | $self->{fontsize} = $fontsize; | |||||||||||||||||||||||||||||||||||||||||
| 124 | my $multiplysize = $fontsize * | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | ▶ | ( defined $opts{'multiply'} ? $opts{'multiply'} : $MULTIPLY ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | ▶ | if ($self->{sevenbitsafe}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->{sevenbitsafe} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | $self->{face} = ""; # computation of face seems useless | |||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | if ($face < 18) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my ($weight, $slope, $expansion) = ("M", "R", "R"); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($face - 12 >= 0) { $expansion = "E"; $face -= 12; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | elsif ($face - 6 >= 0) { $expansion = "C"; $face -= 6; } | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($face - 4 >= 0) { $weight = "L"; $face -= 4; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | elsif ($face - 2 >= 0) { $weight = "B"; $face -= 2; } | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ($face > 0) { $slope = "I"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->{face} = "$weight$slope$expansion"; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | @{$self->{headerrest}}[0 .. $headerrestlength] = split //, $headerrest; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | @width = map { getfixword($_) * $multiplysize } @width; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | @height = map { getfixword($_) * $multiplysize } @height; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | @depth = map { getfixword($_) * $multiplysize } @depth; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | @italic = map { getfixword($_) * $multiplysize } @italic; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 5 | @kern = map { getfixword($_) * $multiplysize } @kern; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | $self->{param}[1] = getfixword($self->{param}[1]); | |||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | @{$self->{param}}[2 .. $self->{numparam}] = | |||||||||||||||||||||||||||||||||||||||||
| 151 | 51 | map { getfixword($_) * $multiplysize } | |||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | @{$self->{param}}[2 .. $self->{numparam}]; | |||||||||||||||||||||||||||||||||||||||||
| 153 | # compute the actual dimensions | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | if (@ligkern) { # check for boundary char | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | my ($skip, $next, $opbyte, $remainder); | |||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | ($skip, $next) = unpack "Ca1", $ligkern[0]; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | ▶ | if ($skip == 255) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->{"boundary"} = $next; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | ($skip, $next, $opbyte, $remainder) = unpack | |||||||||||||||||||||||||||||||||||||||||
| 162 | "Ca1CC", $ligkern[$#ligkern]; | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 4 | ▶ | if ($skip == 255) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | process_lig_kern($self, "boundary", \@ligkern, | |||||||||||||||||||||||||||||||||||||||||
| 165 | 256 * $opbyte + $remainder, \@kern); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | for (0 .. $self->{numofchars} - 1) { | |||||||||||||||||||||||||||||||||||||||||
| 170 | 640 | my $char = pack "C", $_ + $self->{smallest}; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 640 | my ($wid, $heidep, $italtag, $remainder) | |||||||||||||||||||||||||||||||||||||||||
| 172 | = unpack "C4", $charinfo[$_]; | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 640 | ▶ | next if ($wid == 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | # set up dimensions of the character | ||||||||||||||||||||||||||||||||||||||||||
| 175 | ($self->{width}{$char}, $self->{height}{$char}, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 640 | $self->{depth}{$char}, $self->{italic}{$char}) | |||||||||||||||||||||||||||||||||||||||||
| 177 | = ($width[$wid], $height[$heidep >> 4], | ||||||||||||||||||||||||||||||||||||||||||
| 178 | $depth[$heidep & 0x0f], $italic[$italtag >> 2]); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 640 | my $tag = $italtag & 0x03; # other info | |||||||||||||||||||||||||||||||||||||||||
| 181 | 640 | ▶ | if ($tag == 1) { # lig/kern program | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 140 | process_lig_kern($self, $char, \@ligkern, $remainder, \@kern); | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif ($tag == 2) { # larger character | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 74 | $self->{larger}{$char} = pack "C", $remainder; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | elsif ($tag == 3) { # extensible character | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 28 | my ($top, $mid, $bot, $rep) = unpack "C4", $exten[$remainder]; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 28 | ▶ | $self->{extentop}{$char} = pack "C", $top if $top; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 28 | ▶ | $self->{extenmid}{$char} = pack "C", $mid if $mid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 28 | ▶ | $self->{extenbot}{$char} = pack "C", $bot if $bot; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 28 | $self->{extenrep}{$char} = $rep; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | # ################################### | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # Open the file and return filehandle | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | sub open_tfm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_tfm: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | my $filename; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | ▶ | if (defined $opts{file}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | $filename = $opts{file} | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | } elsif (defined $opts{name}) { | |||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | ▶ | $filename = find_tfm_file(%opts) or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | die "No tfm file found for font $opts{name}"; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | die "Either font name or file name has to be specified"; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | # try to open the file | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | ▶ | print STDERR "Loading $filename\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | ▶ | open TFMFILE, $filename or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | die "Error opening $filename: $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 5 | binmode TFMFILE; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | $self->{name} = $filename; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | $self->{name} =~ s/\.tfm$//i; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | $self->{name} =~ s!^.*/!!; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | return(\*TFMFILE); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | # ################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 227 | # Process the ligature/kerning program for a character | ||||||||||||||||||||||||||||||||||||||||||
| 228 | # | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 140 | ▶ | sub process_lig_kern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_lig_kern: called CC=10 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 140 | my ($self, $char, $ligkernref, $prognum, $kernref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 140 | my $firstinstr = 1; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 140 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 233 | 608 | my ($skipbyte, $nextchar, $opbyte, $remainder) | |||||||||||||||||||||||||||||||||||||||||
| 234 | = unpack "Ca1CC", $ligkernref->[$prognum]; | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 608 | ▶ | if ($firstinstr) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 140 | ▶ | if ($skipbyte > 128) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $prognum = 256 * $opbyte + $remainder; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ($skipbyte, $nextchar, $opbyte, $remainder) | |||||||||||||||||||||||||||||||||||||||||
| 239 | = unpack "Ca1CC", $ligkernref->[$prognum]; | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 608 | ▶ | if ($opbyte >= 128 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opbyte >= 128 and not exists $self->{"kern"}{$char . $nextchar}
MC/DC100%2/2
$opbyte >= 128 and not exists $self->{"kern"}{$char . $nextchar}
$opbyte >= 128
not exists $self->{"kern"}{$char . $nextchar}
Truth table100%3/3
A and not(B)
A= $opbyte >= 128B= not exists $self->{"kern"}{$char . $nextchar}
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | and not exists $self->{kern}{$char . $nextchar}) { | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 569 | $self->{kern}{$char . $nextchar} | |||||||||||||||||||||||||||||||||||||||||
| 245 | = $kernref->[ 256 * ($opbyte - 128) | ||||||||||||||||||||||||||||||||||||||||||
| 246 | + $remainder]; | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 608 | ▶ | if ($opbyte < 128 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opbyte < 128 and not exists $self->{"lig"}{$char . $nextchar}
MC/DC50%1/2
$opbyte < 128 and not exists $self->{"lig"}{$char . $nextchar}
$opbyte < 128
not exists $self->{"lig"}{$char . $nextchar}
Truth table66%2/3
A and not(B)
A= $opbyte < 128B= not exists $self->{"lig"}{$char . $nextchar}
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | and not exists $self->{lig}{$char . $nextchar}) { | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 33 | my ($a, $b, $c) = ($opbyte >> 2, ($opbyte >> 1) & 0x01, $opbyte & 0x01); | |||||||||||||||||||||||||||||||||||||||||
| 251 | 33 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 33 | ▶ | $out .= $char if $b; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 33 | $out .= pack "C", $remainder; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 33 | ▶ | $out .= $nextchar if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 33 | $self->{lig}{$char . $nextchar} = $out; | |||||||||||||||||||||||||||||||||||||||||
| 256 | 33 | $self->{ligpassover}{$char . $nextchar} = $a; | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 608 | ▶ | last if ($skipbyte >= 128); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 468 | $prognum += $skipbyte + 1; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 468 | $firstinstr = 0; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | # ################# | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # Find the TFM file | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | ▶ | sub find_tfm_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_tfm_file: called CC=7 SCAR=20.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | my $fontname = $opts{name}; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | ▶ | $fontname .= ".tfm" unless $fontname =~ /\.tfm$/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | ▶ | print STDERR "Font::TFM::find_tfm_file: \$fontname = $fontname\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | my $directory; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | ▶ | for $directory (split /:/, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | (defined $opts{path} ? $opts{path} : $TEXFONTSDIR)) { | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | ▶ | print STDERR "Font::TFM::find_tfm_file: \$directory = $directory\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 5 | my $file = find_tfm_file_in_directory(%opts, | |||||||||||||||||||||||||||||||||||||||||
| 277 | name => $fontname, dir => $directory); | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | ▶ | return $file if defined $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 25 | ▶ | sub find_tfm_file_in_directory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_tfm_file_in_directory: called CC=13 SCAR=30.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 25 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 25 | my ($fontname, $directory) = ($opts{name}, $opts{dir}); | |||||||||||||||||||||||||||||||||||||||||
| 285 | 25 | ▶ | $directory .= '/' unless $directory eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 25 | my $tfmfile = "$directory$fontname"; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 25 | my $lsfile = "$directory$LSFILENAME"; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 25 | ▶ | print STDERR "Font::TFM::find_tfm_file_in_directory: \$directory = $directory\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 25 | ▶ | if (-f $tfmfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | return $tfmfile; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 21 | my $usels = $TEXFONTSUSELS; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 21 | ▶ | if (defined $opts{usels}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $usels = 1; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $usels = 0 if $opts{usels} eq '0' or $opts{usels} eq 'no'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"usels"} eq 0 or $opts{"usels"} eq "no"
MC/DC0%0/2
$opts{"usels"} eq 0 or $opts{"usels"} eq "no"
$opts{"usels"} eq 0
$opts{"usels"} eq "no"
Truth table0%0/3
A or B
A= $opts{"usels"} eq 0B= $opts{"usels"} eq "no"
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 21 | ▶ | if (-f $lsfile and $usels) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $lsfile and $usels
MC/DC0%0/2
-f $lsfile and $usels
-f $lsfile
$usels
Truth table33%1/3
A and B
A= -f $lsfileB= $usels
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $file = find_tfm_file_in_ls($fontname, $lsfile); | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return $file if defined $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 21 | my $subdir; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | for $subdir (<$directory/*>) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 42 | ▶ | next unless -d $subdir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 20 | my $file = find_tfm_file_in_directory(%opts, | |||||||||||||||||||||||||||||||||||||||||
| 306 | dir => $subdir); | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 20 | ▶ | return $file if defined $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub find_tfm_file_in_ls { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_tfm_file_in_ls: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my ($fontname, $lsfile) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $lsdir = $lsfile; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $lsdir =~ s!/$LSFILENAME$!!; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | print STDERR "Font::TFM::find_tfm_file_in_ls: \$lsfile = $lsfile\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | print STDERR "Font::TFM::find_tfm_file_in_ls: \$lsdir = $lsdir\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if (not open LSFILE, $lsfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | Error("Error opening $lsfile: $!"); return; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | local ($/) = "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | while (<LSFILE>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if (/:$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $lsdir = $_; | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $lsdir =~ s!:$!!; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | print STDERR "Font::TFM::find_tfm_file_in_ls: \$lsdir = $lsdir\n" if (DEBUG > 10); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | elsif ($_ eq $fontname) { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $file = "$lsdir/$fontname"; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if (-f $file) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | close LSFILE; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | print STDERR "file $fontname found in $lsfile\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | return $file; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | print STDERR "file $fontname not found in $lsfile\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 447 | ▶ | sub getfixword { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getfixword: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 447 | my $val = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 447 | my $p = pack "L", $val; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 447 | ▶ | if ($val & 0x80000000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 26 | $val = unpack "l", $p; | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 447 | return ($val / (1 << 20)); | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 2 | ▶ | sub kern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kern: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 2 | my ($self, $double, $second) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | ▶ | $double .= $second if (defined $second); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 2 | ▶ | if (defined $self->{kern}{$double}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | return $self->{kern}{$double}; | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | sub lig { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lig: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my ($self, $double, $second) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $double .= $second if (defined $second); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if (defined $self->{lig}{$double}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | return $self->{lig}{$double}; | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub ligpassover { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ligpassover: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ($self, $double) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $self->{ligpassover}{$double}; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub param { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ($self, $param) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $self->{param}[$param]; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | sub word_dimensions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
word_dimensions: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my @expanded = $self->expand($text); | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my ($width, $height, $depth) = (0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | while (@expanded) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $word = shift @expanded; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | while ($word =~ /./sg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $char = $&; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $width += $self->width($char); | |||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $newval = $self->height($char); | |||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | $height = $newval if ($newval > $height); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $newval = $self->depth($char); | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $depth = $newval if ($newval > $depth); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | last if (not @expanded); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $width += shift @expanded; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ($width, $height, $depth); | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | sub expand { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $pos = 0; | |||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | # ligature substitutions | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | while ($pos < (length $text) - 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $substr = substr $text, $pos, 2; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $found = $self->lig(substr $text, $pos, 2); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if (defined $found) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | substr($text, $pos, 2) = $found; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $pos += $self->ligpassover($substr); | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | else | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | { $pos++ } | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | # kerning processing | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my @out = (); | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $currentstring = substr $text, 0, 1; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | while ($text =~ /(.)(?=(.))/gs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ($self->kern($1 . $2)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | push @out, $currentstring; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $currentstring = ''; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | push @out, $self->kern($1 . $2); | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $currentstring .= $2 | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | push @out, $currentstring; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | @out; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | my %PARAM_NAMES = ( slant => 1, space => 2, spacestretch => 3, | |||||||||||||||||||||||||||||||||||||||||
| 426 | spaceshrink => 4, xheight => 5, emwidth => 6, quad => 6, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | extraspace => 7, | ||||||||||||||||||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | my @GENERAL_NAMES = qw( fontsize designsize name checksum codingscheme ); | |||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | my @CHAR_NAMES = qw( width height depth italic ); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | my %WORD_NAMES = ( word_width => 0, word_height => 1, word_depth => 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | my %MATH_SY_NAMES = ( num1 => 8, num2 => 9, num3 => 10, | |||||||||||||||||||||||||||||||||||||||||
| 433 | denom1 => 11, denom2 => 12, | ||||||||||||||||||||||||||||||||||||||||||
| 434 | sup1 => 13, sup2 => 14, sup3 => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 435 | sub1 => 16, sub2 => 17, | ||||||||||||||||||||||||||||||||||||||||||
| 436 | supdrop => 18, | ||||||||||||||||||||||||||||||||||||||||||
| 437 | subdrop => 19, | ||||||||||||||||||||||||||||||||||||||||||
| 438 | delim1 => 20, delim2 => 21, | ||||||||||||||||||||||||||||||||||||||||||
| 439 | axisheight => 22, | ||||||||||||||||||||||||||||||||||||||||||
| 440 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | my %MATH_EX_NAMES = ( | |||||||||||||||||||||||||||||||||||||||||
| 442 | defaultrulethickness => 8, | ||||||||||||||||||||||||||||||||||||||||||
| 443 | bigopspacing1 => 9, | ||||||||||||||||||||||||||||||||||||||||||
| 444 | bigopspacing2 => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 445 | bigopspacing3 => 11, | ||||||||||||||||||||||||||||||||||||||||||
| 446 | bigopspacing4 => 12, | ||||||||||||||||||||||||||||||||||||||||||
| 447 | bigopspacing5 => 13, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | ▶ | use vars qw( $AUTOLOAD ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 13 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 13 | my $function = $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 13 | local ($_); | |||||||||||||||||||||||||||||||||||||||||
| 455 | 13 | $function =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 13 | $function =~ s/_//g; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 13 | ▶ | print STDERR "Autoloading $function\n" if DEBUG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | return ($self->word_dimensions(shift))[$WORD_NAMES{$function}] | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 13 | ▶ | if defined $WORD_NAMES{$function}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | return $self->{'param'}[$PARAM_NAMES{$function}] | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 13 | ▶ | if (defined $PARAM_NAMES{$function}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | return $self->{$function}{$_[0]} | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 11 | ▶ | if grep { $_ eq $function } @CHAR_NAMES; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | return $self->{$function} | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 8 | ▶ | if grep { $_ eq $function } @GENERAL_NAMES; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 6 | ▶ | if ($self->{codingscheme} eq 'TeX math symbols' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"codingscheme"} eq "TeX math symbols" and defined $MATH_SY_NAMES{$function}
MC/DC50%1/2
$self->{"codingscheme"} eq "TeX math symbols" and defined $MATH_SY_NAMES{$function}
$self->{"codingscheme"} eq "TeX math symbols"
defined $MATH_SY_NAMES{$function}
Truth table66%2/3
A and B
A= $self->{"codingscheme"} eq "TeX math symbols"B= defined $MATH_SY_NAMES{$function}
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | and defined $MATH_SY_NAMES{$function}) { | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | return $self->{'param'}[$MATH_SY_NAMES{$function}] | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 4 | ▶ | if ($self->{codingscheme} eq 'TeX math extension' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"codingscheme"} eq "TeX math extension" and defined $MATH_EX_NAMES{$function}
MC/DC50%1/2
$self->{"codingscheme"} eq "TeX math extension" and defined $MATH_EX_NAMES{$function}
$self->{"codingscheme"} eq "TeX math extension"
defined $MATH_EX_NAMES{$function}
Truth table66%2/3
A and B
A= $self->{"codingscheme"} eq "TeX math extension"B= defined $MATH_EX_NAMES{$function}
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | and defined $MATH_EX_NAMES{$function}) { | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 2 | return $self->{'param'}[$MATH_EX_NAMES{$function}] | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | die "Method $function not defined for $self"; | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub Version { $VERSION; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | __END__ | ||||||||||||||||||||||||||||||||||||||||||