| 1 | package Font::TTF::Cmap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Font::TTF::Cmap - Character map table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Looks after the character map. For ease of use, the actual cmap is held in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | a hash against codepoint. Thus for a given table: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | $gid = $font->{'cmap'}{'Tables'}[0]{'val'}{$code}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | Note that C<$code> should be a true value (0x1234) rather than a string representation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 INSTANCE VARIABLES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | The instance variables listed here are not preceded by a space due to their | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | emulating structural information in the font. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =item Num | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | Number of subtables in this table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =item Tables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | An array of subtables ([0..Num-1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | Each subtable also has its own instance variables which are, again, not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | preceded by a space. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =item Platform | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | The platform number for this subtable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | =item Encoding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | The encoding number for this subtable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | =item Format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | Gives the stored format of this subtable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | =item Ver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | Gives the version (or language) information for this subtable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | =item val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | A hash keyed by the codepoint value (not a string) storing the glyph id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | The following cmap options are controlled by instance variables that start with a space: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | =item allowholes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | By default, when generating format 4 cmap subtables character codes that point to glyph zero | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | (normally called .notdef) are not included in the subtable. In some cases including some of these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | character codes can result in a smaller format 4 subtable. To enable this behavior, set allowholes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | to non-zero. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | use Font::TTF::Table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | use Font::TTF::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | @ISA = qw(Font::TTF::Table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =head2 $t->read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | Reads the cmap into memory. Format 4 subtables read the whole subtable and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | fill in the segmented array accordingly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=39 SCAR=61.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | my ($self, $keepzeros) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | $self->SUPER::read or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my ($dat, $i, $j, $k, $id, @ids, $s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | my ($start, $end, $range, $delta, $form, $len, $num, $ver, $sg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my ($fh) = $self->{' INFILE'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | $fh->read($dat, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | $self->{'Num'} = unpack("x2n", $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2 | $self->{'Tables'} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | for ($i = 0; $i < $self->{'Num'}; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | $s = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | $fh->read($dat, 8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ($s->{'Platform'}, $s->{'Encoding'}, $s->{'LOC'}) = (unpack("nnN", $dat)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | $s->{'LOC'} += $self->{' OFFSET'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | push(@{$self->{'Tables'}}, $s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | ▶ | for ($i = 0; $i < $self->{'Num'}; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 4 | $s = $self->{'Tables'}[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 4 | $fh->seek($s->{'LOC'}, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | $fh->read($dat, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | $form = unpack("n", $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | $s->{'Format'} = $form; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | ▶ | if ($form == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $fh->read($dat, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ($len, $s->{'Ver'}) = unpack('n2', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $fh->read($dat, 256); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $s->{'val'} = {map {$j++; ($_ ? ($j - 1, $_) : ())} unpack("C*", $dat)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } elsif ($form == 6) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my ($start, $ecount); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $fh->read($dat, 8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ($len, $s->{'Ver'}, $start, $ecount) = unpack('n4', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $fh->read($dat, $ecount << 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | $s->{'val'} = {map {$start++; ($_ ? ($start - 1, $_) : ())} unpack("n*", $dat)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } elsif ($form == 2) # Contributed by Huw Rogers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $fh->read($dat, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ($len, $s->{'Ver'}) = unpack('n2', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $fh->read($dat, 512); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my ($j, $k, $l, $m, $n, @subHeaderKeys, @subHeaders, $subHeader); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $n = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | for ($j = 0; $j < 256; $j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $k = unpack('@'.($j<<1).'n', $dat)>>3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $n = $k + 1 if $k >= $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $subHeaders[$subHeaderKeys[$j] = $k] ||= [ ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$subHeaders[$subHeaderKeys[$j] = $k] ||= []
MC/DC0%0/1
$subHeaders[$subHeaderKeys[$j] = $k] ||= []
$subHeaders[$subHeaderKeys[$j] = $k]
Truth table0%0/2
A
A= $subHeaders[$subHeaderKeys[$j] = $k]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $fh->read($dat, $n<<3); # read subHeaders[] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | for ($k = 0; $k < $n; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $subHeader = $subHeaders[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $l = $k<<3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | @$subHeader = unpack('@'.$l.'n4', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $subHeader->[2] = unpack('s', pack('S', $subHeader->[2])) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | if $subHeader->[2] & 0x8000; # idDelta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $subHeader->[3] = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ($subHeader->[3] - (($n - $k)<<3) + 6)>>1; # idRangeOffset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $fh->read($dat, $len - ($n<<3) - 518); # glyphIndexArray[] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | for ($j = 0; $j < 256; $j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $k = $subHeaderKeys[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $subHeader = $subHeaders[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | unless ($k) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $l = $j - $subHeader->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ($l >= 0 && $l < $subHeader->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$l >= 0 and $l < $subHeader->[1]
MC/DC0%0/2
$l >= 0 and $l < $subHeader->[1]
$l >= 0
$l < $subHeader->[1]
Truth table0%0/3
A and B
A= $l >= 0B= $l < $subHeader->[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $m = unpack('@'.(($l + $subHeader->[3])<<1).'n', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $m += $subHeader->[2] if $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $s->{'val'}{$j} = $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | for ($l = 0; $l < $subHeader->[1]; $l++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $m = unpack('@'.(($l + $subHeader->[3])<<1).'n', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $m += $subHeader->[2] if $m; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $s->{'val'}{($j<<8) + $l + $subHeader->[0]} = $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } elsif ($form == 4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | $fh->read($dat, 12); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 4 | ($len, $s->{'Ver'}, $num) = unpack('n3', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4 | $num >>= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | $fh->read($dat, $len - 14); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 4 | ▶ | for ($j = 0; $j < $num; $j++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 8 | $end = unpack("n", substr($dat, $j << 1, 2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | $start = unpack("n", substr($dat, ($j << 1) + ($num << 1) + 2, 2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | $delta = unpack("n", substr($dat, ($j << 1) + ($num << 2) + 2, 2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | ▶ | $delta -= 65536 if $delta > 32767; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | $range = unpack("n", substr($dat, ($j << 1) + $num * 6 + 2, 2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8 | ▶ | for ($k = $start; $k <= $end; $k++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 384 | ▶ | if ($range == 0 || $range == 65535) # support the buggy FOG with its range=65535 for final segment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$range == 0 or $range == 65535
MC/DC0%0/2
$range == 0 or $range == 65535
$range == 0
$range == 65535
Truth table33%1/3
A or B
A= $range == 0B= $range == 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 384 | { $id = $k + $delta; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | { $id = unpack("n", substr($dat, ($j << 1) + $num * 6 + | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 + ($k - $start) * 2 + $range, 2)) + $delta; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 384 | ▶ | $id -= 65536 if $id >= 65536; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 384 | ▶ | $s->{'val'}{$k} = $id if ($id || $keepzeros); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$id or $keepzeros
MC/DC50%1/2
$id or $keepzeros
$id
$keepzeros
Truth table66%2/3
A or B
A= $idB= $keepzeros
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ▶ | } elsif ($form == 8 || $form == 12 || $form == 13) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$form == 8 or $form == 12 or $form == 13
$form == 8 or $form == 12
MC/DC0%0/3
$form == 8 or $form == 12 or $form == 13
$form == 8
$form == 12
$form == 13
Truth table0%0/4
A or B or C
A= $form == 8B= $form == 12C= $form == 13
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $fh->read($dat, 10); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ($len, $s->{'Ver'}) = unpack('x2N2', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ($form == 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $fh->read($dat, 8196); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $num = unpack("N", substr($dat, 8192, 4)); # don't need the map | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $fh->read($dat, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $num = unpack("N", $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $fh->read($dat, 12 * $num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | for ($j = 0; $j < $num; $j++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ($start, $end, $sg) = unpack("N3", substr($dat, $j * 12, 12)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | for ($k = $start; $k <= $end; $k++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | { $s->{'val'}{$k} = $form == 13 ? $sg : $sg++; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } elsif ($form == 10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $fh->read($dat, 18); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ($len, $s->{'Ver'}, $start, $num) = unpack('x2N4', $dat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $fh->read($dat, $num << 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | for ($j = 0; $j < $num; $j++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | { $s->{'val'}{$start + $j} = unpack("n", substr($dat, $j << 1, 2)); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | =head2 $t->ms_lookup($uni) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | Finds a Unicode table, giving preference to the MS one, and looks up the given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | Unicode codepoint in it to find the glyph id. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub ms_lookup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ms_lookup: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my ($self, $uni) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | $self->find_ms || return undef unless (defined $self->{' mstable'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
defined $self->{' mstable'} || ($self->find_ms || (return undef))
$self->find_ms or return undef
MC/DC0%0/2
defined $self->{' mstable'} || ($self->find_ms || (return undef))
defined $self->{' mstable'}
$self->find_ms
Truth table0%0/3
A || B
A= defined $self->{' mstable'}B= $self->find_ms
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return $self->{' mstable'}{'val'}{$uni}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | =head2 $t->find_ms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | Finds the a Unicode table, giving preference to the Microsoft one, and sets the C<mstable> instance variable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | to it if found. Returns the table it finds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | sub find_ms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_ms: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my ($i, $s, $alt, $found); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return $self->{' mstable'} if defined $self->{' mstable'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->read; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | for ($i = 0; $i < $self->{'Num'}; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $s = $self->{'Tables'}[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if ($s->{'Platform'} == 3) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->{' mstable'} = $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | return $s if ($s->{'Encoding'} == 10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $found = 1 if ($s->{'Encoding'} == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ▶ | } elsif ($s->{'Platform'} == 0 || ($s->{'Platform'} == 2 && $s->{'Encoding'} == 1)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$s->{"Platform"} == 0 or $s->{"Platform"} == 2 and $s->{"Encoding"} == 1
$s->{"Platform"} == 2 and $s->{"Encoding"} == 1
MC/DC0%0/3
$s->{"Platform"} == 0 or $s->{"Platform"} == 2 and $s->{"Encoding"} == 1
$s->{"Platform"} == 0
$s->{"Platform"} == 2
$s->{"Encoding"} == 1
Truth table0%0/4
A or B and C
A= $s->{"Platform"} == 0B= $s->{"Platform"} == 2C= $s->{"Encoding"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | { $alt = $s; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $self->{' mstable'} = $alt if ($alt && !$found); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$alt and not $found
MC/DC0%0/2
$alt and not $found
$alt
not $found
Truth table0%0/3
A and not(B)
A= $altB= not $found
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $self->{' mstable'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | =head2 $t->ms_enc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | Returns the encoding of the microsoft table (0 => symbol, etc.). Returns undef if there is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | no Microsoft cmap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | sub ms_enc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ms_enc: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my ($s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | return $self->{' mstable'}{'Encoding'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if (defined $self->{' mstable'} && $self->{' mstable'}{'Platform'} == 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{" mstable"} and $self->{" mstable"}{"Platform"} == 3
MC/DC0%0/2
defined $self->{" mstable"} and $self->{" mstable"}{"Platform"} == 3
defined $self->{" mstable"}
$self->{" mstable"}{"Platform"} == 3
Truth table0%0/3
A and B
A= defined $self->{" mstable"}B= $self->{" mstable"}{"Platform"} == 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | foreach $s (@{$self->{'Tables'}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | return $s->{'Encoding'} if ($s->{'Platform'} == 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | =head2 $t->out($fh) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | Writes out a cmap table to a filehandle. If it has not been read, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | just copies from input file to output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | sub out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
out: called CC=68 SCAR=74.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | my ($loc, $s, $i, $base_loc, $j, @keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2 | ▶ | return $self->SUPER::out($fh) unless $self->{' read'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $self->{'Tables'} = [sort {$a->{'Platform'} <=> $b->{'Platform'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | || $a->{'Encoding'} <=> $b->{'Encoding'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | ▶ | || $a->{'Ver'} <=> $b->{'Ver'}} @{$self->{'Tables'}}]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$Font::TTF::Cmap::a->{'Platform'} <=> $Font::TTF::Cmap::b->{'Platform'} || $Font::TTF::Cmap::a->{'Encoding'} <=> $Font::TTF::Cmap::b->{'Encoding'} || $Font::TTF::Cmap::a->{'Ver'} <=> $Font::TTF::Cmap::b->{'Ver'}
$Font::TTF::Cmap::a->{"Platform"} <=> $Font::TTF::Cmap::b->{"Platform"} or $Font::TTF::Cmap::a->{"Encoding"} <=> $Font::TTF::Cmap::b->{"Encoding"}
MC/DC0%0/3
$Font::TTF::Cmap::a->{'Platform'} <=> $Font::TTF::Cmap::b->{'Platform'} || $Font::TTF::Cmap::a->{'Encoding'} <=> $Font::TTF::Cmap::b->{'Encoding'} || $Font::TTF::Cmap::a->{'Ver'} <=> $Font::TTF::Cmap::b->{'Ver'}
$Font::TTF::Cmap::a->{"Platform"} <=> $Font::TTF::Cmap::b->{"Platform"}
$Font::TTF::Cmap::a->{"Encoding"} <=> $Font::TTF::Cmap::b->{"Encoding"}
$Font::TTF::Cmap::a->{'Ver'} <=> $Font::TTF::Cmap::b->{'Ver'}
Truth table25%1/4
A or B || C
A= $Font::TTF::Cmap::a->{"Platform"} <=> $Font::TTF::Cmap::b->{"Platform"}B= $Font::TTF::Cmap::a->{"Encoding"} <=> $Font::TTF::Cmap::b->{"Encoding"}C= $Font::TTF::Cmap::a->{'Ver'} <=> $Font::TTF::Cmap::b->{'Ver'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | $self->{'Num'} = scalar @{$self->{'Tables'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | $base_loc = $fh->tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | $fh->print(pack("n2", 0, $self->{'Num'})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | ▶ | for ($i = 0; $i < $self->{'Num'}; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 4 | { $fh->print(pack("nnN", $self->{'Tables'}[$i]{'Platform'}, $self->{'Tables'}[$i]{'Encoding'}, 0)); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | ▶ | for ($i = 0; $i < $self->{'Num'}; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 4 | $s = $self->{'Tables'}[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | ▶ | if ($s->{'Format'} < 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 4 | { @keys = sort {$a <=> $b} grep { $_ <= 0xFFFF} keys %{$s->{'val'}}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | { @keys = sort {$a <=> $b} keys %{$s->{'val'}}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | $s->{' outloc'} = $fh->tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 4 | ▶ | if ($s->{'Format'} < 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | { $fh->print(pack("n3", $s->{'Format'}, 0, $s->{'Ver'})); } # come back for length | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | { $fh->print(pack("n2N2", $s->{'Format'}, 0, 0, $s->{'Ver'})); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | ▶ | if ($s->{'Format'} == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | $fh->print(pack("C256", map {defined $_ ? $_ : 0} @{$s->{'val'}}{0 .. 255})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } elsif ($s->{'Format'} == 6) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $fh->print(pack("n2", $keys[0], $keys[-1] - $keys[0] + 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | $fh->print(pack("n*", map {defined $_ ? $_ : 0} @{$s->{'val'}}{$keys[0] .. $keys[-1]})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } elsif ($s->{'Format'} == 2) # Contributed by Huw Rogers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my ($g, $k, $h, $l, $m, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my (@subHeaderKeys, @subHeaders, $subHeader, @glyphIndexArray); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | @subHeaderKeys = (-1) x 256; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | for $j (@keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | next unless defined($g = $s->{'val'}{$j}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $h = int($j>>8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $l = ($j & 0xff); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if (($k = $subHeaderKeys[$h]) < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $subHeader = [ $l, 1, 0, 0, [ $g ] ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $subHeaders[$k = $n++] = $subHeader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $subHeaderKeys[$h] = $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $subHeader = $subHeaders[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $m = ($l - $subHeader->[0] + 1) - $subHeader->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $subHeader->[1] += $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | push @{$subHeader->[4]}, (0) x ($m - 1), $g - $subHeader->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | @subHeaderKeys = map { $_ < 0 ? 0 : $_ } @subHeaderKeys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $subHeader = $subHeaders[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $subHeader->[3] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | push @glyphIndexArray, @{$subHeader->[4]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | splice(@$subHeader, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my @subHeaders_ = sort {@{$a->[4]} <=> @{$b->[4]}} @subHeaders[1..$#subHeaders]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my ($f, $d, $r, $subHeader_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | for ($k = 0; $k < @subHeaders_; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $subHeader = $subHeaders_[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $f = $r = shift @{$subHeader->[4]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | $subHeader->[5] = join(':', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $d = $_ - $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $r = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $d < 0 ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | sprintf('-%04x', -$d) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | sprintf('+%04x', $d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | } @{$subHeader->[4]}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | unshift @{$subHeader->[4]}, $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | for ($k = 0; $k < @subHeaders_; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $subHeader = $subHeaders_[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | next unless $subHeader->[4]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $subHeader->[3] = @glyphIndexArray; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | push @glyphIndexArray, @{$subHeader->[4]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | for ($l = $k + 1; $l < @subHeaders_; $l++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $subHeader_ = $subHeaders_[$l]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | next unless $subHeader_->[4]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $d = $subHeader_->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ($subHeader->[5] =~ /\Q$d\E/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $o = length($`)/6; #` | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $subHeader_->[2] += | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | $subHeader_->[4]->[$o] - $subHeader->[4]->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $subHeader_->[3] = $subHeader->[3] + $o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | splice(@$subHeader_, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | splice(@$subHeader, 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $fh->print(pack('n*', map { $_<<3 } @subHeaderKeys)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | for ($j = 0; $j < 256; $j++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $k = $subHeaderKeys[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $subHeader = $subHeaders[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | for ($k = 0; $k < $n; $k++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $subHeader = $subHeaders[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | $fh->print(pack('n4', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | $subHeader->[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | $subHeader->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | $subHeader->[2] < 0 ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | unpack('S', pack('s', $subHeader->[2])) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | $subHeader->[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ($subHeader->[3]<<1) + (($n - $k)<<3) - 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $fh->print(pack('n*', @glyphIndexArray)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } elsif ($s->{'Format'} == 4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 4 | my (@starts, @ends, @deltas, @range); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # There appears to be a bug in Windows that requires the final 0xFFFF (sentry) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # to be in a segment by itself -- otherwise Windows 7 and 8 (at least) won't install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # or preview the font, complaining that it doesn't appear to be a valid font. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # Therefore we can't just add 0XFFFF to the USV list as we used to do: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # push(@keys, 0xFFFF) unless ($keys[-1] == 0xFFFF); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # Instead, for now *remove* 0xFFFF from the USV list, and add a segement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # for it after all the other segments are computed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 4 | ▶ | pop @keys if $keys[-1] == 0xFFFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # Step 1: divide into maximal length idDelta runs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 4 | my ($prevUSV, $prevgid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 4 | ▶ | for ($j = 0; $j <= $#keys; $j++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 380 | my $u = $keys[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 380 | my $g = $s->{'val'}{$u}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 380 | ▶ | if ($j == 0 || $u != $prevUSV+1 || $g != $prevgid+1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$j == 0 or $u != $prevUSV + 1 or $g != $prevgid + 1
$j == 0 or $u != $prevUSV + 1
MC/DC33%1/3
$j == 0 or $u != $prevUSV + 1 or $g != $prevgid + 1
$j == 0
$u != $prevUSV + 1
$g != $prevgid + 1
Truth table50%2/4
A or B or C
A= $j == 0B= $u != $prevUSV + 1C= $g != $prevgid + 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 4 | ▶ | push @ends, $prevUSV unless $j == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 4 | push @starts, $u; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 4 | push @range, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 380 | $prevUSV = $u; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 380 | $prevgid = $g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 4 | push @ends, $prevUSV; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # Step 2: find each macro-range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 4 | my ($start, $end); # Start and end of macro-range | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 4 | ▶ | for ($start = 0; $start < $#starts; $start++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | next if $ends[$start] - $starts[$start] > 7; # if count > 8, we always treat this as a run unto itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | for ($end = $start+1; $end <= $#starts; $end++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | last if $starts[$end] - $ends[$end-1] > ($self->{' allowholes'} ? 5 : 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$starts[$end] - $ends[$end - 1] > ($self->{" allowholes"} ? 5 : 1) or $ends[$end] - $starts[$end] > 7
MC/DC0%0/2
$starts[$end] - $ends[$end - 1] > ($self->{" allowholes"} ? 5 : 1) or $ends[$end] - $starts[$end] > 7
$starts[$end] - $ends[$end - 1] > ($self->{" allowholes"} ? 5 : 1)
$ends[$end] - $starts[$end] > 7
Truth table0%0/3
A or B
A= $starts[$end] - $ends[$end - 1] > ($self->{" allowholes"} ? 5 : 1)B= $ends[$end] - $starts[$end] > 7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | || $ends[$end] - $starts[$end] > 7; # gap > 4 or count > 8 so $end is beyond end of macro-range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $end--; #Ending index of this macro-range | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # Step 3: optimize this macro-range (from $start through $end) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | L1: for ($j = $start; $j < $end; ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | my $size1 = ($range[$j] ? 8 + 2 * ($ends[$j] - $starts[$j] + 1) : 8); # size of first range (which may now be idRange type) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | for (my $k = $j+1; $k <= $end; $k++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if (8 + 2 * ($ends[$k] - $starts[$j] + 1) <= $size1 + 8 * ($k - $j)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Need to coalesce $j..$k into $j: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $ends[$j] = $ends[$k]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $range[$j] = 1; # for now use boolean to indicate this is an idRange segment | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | splice @starts, $j+1, $k-$j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | splice @ends, $j+1, $k-$j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | splice @range, $j+1, $k-$j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $end -= ($k-$j); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | next L1; # Note that $j isn't incremented so this is a redo | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # Nothing coalesced | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # Finished with this macro-range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $start = $end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # Ok, add the final segment containing the sentry value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 4 | push(@keys, 0xFFFF); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 4 | push @starts, 0xFFFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 4 | push @ends, 0xFFFF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | push @range, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # What is left is a collection of segments that will represent the cmap in mimimum-sized format 4 subtable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 4 | my ($num, $count, $sRange, $eSel, $eShift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | $num = scalar(@starts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 4 | $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | ▶ | for ($j = 0; $j < $num; $j++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 8 | ▶ | if ($range[$j]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $range[$j] = ($count + $num - $j) << 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $count += $ends[$j] - $starts[$j] + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | push @deltas, 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 8 | ▶ | push @deltas, ($s->{'val'}{$starts[$j]} || 0) - $starts[$j]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$s->{'val'}{$starts[$j]} || 0
MC/DC100%1/1
$s->{'val'}{$starts[$j]} || 0
$s->{'val'}{$starts[$j]}
Truth table100%2/2
A
A= $s->{'val'}{$starts[$j]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 4 | ($num, $sRange, $eSel, $eShift) = Font::TTF::Utils::TTF_bininfo($num, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | $fh->print(pack("n4", $num * 2, $sRange, $eSel, $eShift)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 4 | $fh->print(pack("n*", @ends)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 4 | $fh->print(pack("n", 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 4 | $fh->print(pack("n*", @starts)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 4 | $fh->print(pack("n*", @deltas)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 4 | $fh->print(pack("n*", @range)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 4 | ▶ | for ($j = 0; $j < $num; $j++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 8 | ▶ | next if ($range[$j] == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | $fh->print(pack("n*", map {$_ || 0} @{$s->{'val'}}{$starts[$j] .. $ends[$j]})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ || 0
MC/DC0%0/1
$_ || 0
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | ▶ | } elsif ($s->{'Format'} == 8 || $s->{'Format'} == 12 || $s->{'Format'} == 13) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$s->{"Format"} == 8 or $s->{"Format"} == 12 or $s->{"Format"} == 13
$s->{"Format"} == 8 or $s->{"Format"} == 12
MC/DC0%0/3
$s->{"Format"} == 8 or $s->{"Format"} == 12 or $s->{"Format"} == 13
$s->{"Format"} == 8
$s->{"Format"} == 12
$s->{"Format"} == 13
Truth table0%0/4
A or B or C
A= $s->{"Format"} == 8B= $s->{"Format"} == 12C= $s->{"Format"} == 13
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my (@jobs, $start, $current, $curr_glyf, $map); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $current = 0; $curr_glyf = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $map = "\000" x 8192; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | foreach $j (@keys) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if ($j > 0xFFFF && $s->{'Format'} == 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$j > 65535 and $s->{"Format"} == 8
MC/DC0%0/2
$j > 65535 and $s->{"Format"} == 8
$j > 65535
$s->{"Format"} == 8
Truth table0%0/3
A and B
A= $j > 65535B= $s->{"Format"} == 8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | if (defined $s->{'val'}{$j >> 16}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | { $s->{'Format'} = 12; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | vec($map, $j >> 16, 1) = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ($j != $current + 1 || $s->{'val'}{$j} != ($s->{'Format'} == 13 ? $curr_glyf : $curr_glyf + 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$j != $current + 1 or $s->{"val"}{$j} != ($s->{"Format"} == 13 ? $curr_glyf : $curr_glyf + 1)
MC/DC0%0/2
$j != $current + 1 or $s->{"val"}{$j} != ($s->{"Format"} == 13 ? $curr_glyf : $curr_glyf + 1)
$j != $current + 1
$s->{"val"}{$j} != ($s->{"Format"} == 13 ? $curr_glyf : $curr_glyf + 1)
Truth table0%0/3
A or B
A= $j != $current + 1B= $s->{"val"}{$j} != ($s->{"Format"} == 13 ? $curr_glyf : $curr_glyf + 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | push (@jobs, [$start, $current, $s->{'Format'} == 13 ? $curr_glyf : $curr_glyf - ($current - $start)]) if (defined $start); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $start = $j; $current = $j; $curr_glyf = $s->{'val'}{$j}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $current = $j; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $curr_glyf = $s->{'val'}{$j}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | push (@jobs, [$start, $current, $s->{'Format'} == 13 ? $curr_glyf : $curr_glyf - ($current - $start)]) if (defined $start); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | $fh->print($map) if ($s->{'Format'} == 8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $fh->print(pack('N', $#jobs + 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | foreach $j (@jobs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | { $fh->print(pack('N3', @{$j})); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } elsif ($s->{'Format'} == 10) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | $fh->print(pack('N2', $keys[0], $keys[-1] - $keys[0] + 1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $fh->print(pack('n*', $s->{'val'}{$keys[0] .. $keys[-1]})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 4 | $loc = $fh->tell(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 4 | ▶ | if ($s->{'Format'} < 8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 4 | $fh->seek($s->{' outloc'} + 2, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 4 | $fh->print(pack("n", $loc - $s->{' outloc'})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $fh->seek($s->{' outloc'} + 4, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $fh->print(pack("N", $loc - $s->{' outloc'})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 4 | $fh->seek($base_loc + 8 + ($i << 3), 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 4 | $fh->print(pack("N", $s->{' outloc'} - $base_loc)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | $fh->seek($loc, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 2 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | =head2 $t->XML_element($context, $depth, $name, $val) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | Outputs the elements of the cmap in XML. We only need to process val here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | sub XML_element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XML_element: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my ($self, $context, $depth, $k, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my ($fh) = $context->{'fh'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my ($i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | return $self if ($k eq 'LOC'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | return $self->SUPER::XML_element($context, $depth, $k, $val) unless ($k eq 'val'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $fh->print("$depth<mappings>\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | foreach $i (sort {$a <=> $b} keys %{$val}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | { $fh->printf("%s<map code='%04X' glyph='%s'/>\n", $depth . $context->{'indent'}, $i, $val->{$i}); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $fh->print("$depth</mappings>\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | =head2 $t->minsize() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | Returns the minimum size this table can be in bytes. If it is smaller than this, then the table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | must be bad and should be deleted or whatever. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | sub minsize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minsize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | return 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | =head2 $t->update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | Tidies the cmap table. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | Removes MS Fmt12 cmap if it is no longer needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | Removes from all cmaps any codepoint that map to GID=0. Note that such entries will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | be re-introduced as necessary depending on the cmap format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | sub update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | my ($max, $code, $gid, @keep); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | return undef unless ($self->SUPER::update); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | foreach my $s (@{$self->{'Tables'}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $max = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | while (($code, $gid) = each %{$s->{'val'}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | if ($gid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # remember max USV | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | $max = $code if $max < $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # Remove unneeded key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | delete $s->{'val'}{$code}; # nb: this is a safe delete according to perldoc perlfunc. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | push @keep, $s unless $s->{'Platform'} == 3 && $s->{'Encoding'} == 10 && $s->{'Format'} == 12 && $max <= 0xFFFF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$s->{"Platform"} == 3 and $s->{"Encoding"} == 10 and $s->{"Format"} == 12 and $max <= 65535
$s->{"Platform"} == 3 and $s->{"Encoding"} == 10 and $s->{"Format"} == 12
$s->{"Platform"} == 3 and $s->{"Encoding"} == 10
MC/DC0%0/4
$s->{"Platform"} == 3 and $s->{"Encoding"} == 10 and $s->{"Format"} == 12 and $max <= 65535
$s->{"Platform"} == 3
$s->{"Encoding"} == 10
$s->{"Format"} == 12
$max <= 65535
Truth table0%0/5
A and B and C and D
A= $s->{"Platform"} == 3B= $s->{"Encoding"} == 10C= $s->{"Format"} == 12D= $max <= 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $self->{'Tables'} = [ @keep ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | delete $self->{' mstable'}; # Force rediscovery of this. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | =head2 @map = $t->reverse(%opt) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | Returns a reverse map of the Unicode cmap. I.e. given a glyph gives the Unicode value for it. Options are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | =item tnum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | Table number to use rather than the default Unicode table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | =item array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | Returns each element of reverse as an array since a glyph may be mapped by more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | than one Unicode value. The arrays are unsorted. Otherwise store any one unicode value for a glyph. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | sub reverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reverse: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my ($self, %opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | my ($table) = defined $opt{'tnum'} ? $self->{'Tables'}[$opt{'tnum'}] : $self->find_ms; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my (@res, $code, $gid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | while (($code, $gid) = each(%{$table->{'val'}})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | if ($opt{'array'}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | { push (@{$res[$gid]}, $code); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | { $res[$gid] = $code unless (defined $res[$gid] && $res[$gid] > 0 && $res[$gid] < $code); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $res[$gid] and $res[$gid] > 0 and $res[$gid] < $code
defined $res[$gid] and $res[$gid] > 0
MC/DC0%0/3
defined $res[$gid] and $res[$gid] > 0 and $res[$gid] < $code
defined $res[$gid]
$res[$gid] > 0
$res[$gid] < $code
Truth table0%0/4
A and B and C
A= defined $res[$gid]B= $res[$gid] > 0C= $res[$gid] < $code
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | =head2 is_unicode($index) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | Returns whether the table of a given index is known to be a unicode table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | (as specified in the specifications) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | sub is_unicode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unicode: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my ($self, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my ($pid, $eid) = ($self->{'Tables'}[$index]{'Platform'}, $self->{'Tables'}[$index]{'Encoding'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | return ($pid == 3 || $pid == 0 || ($pid == 2 && $eid == 1)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$pid == 3 || $pid == 0 || $pid == 2 && $eid == 1
$pid == 3 or $pid == 0
$pid == 2 and $eid == 1
MC/DC0%0/4
$pid == 3 || $pid == 0 || $pid == 2 && $eid == 1
$pid == 3
$pid == 0
$pid == 2
$eid == 1
Truth table0%0/5
A or B || C and D
A= $pid == 3B= $pid == 0C= $pid == 2D= $eid == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | =item * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | Format 14 (Unicode Variation Sequences) cmaps are not supported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | Martin Hosken L<http://scripts.sil.org/FontUtils>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | =head1 LICENSING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | Copyright (c) 1998-2016, SIL International (http://www.sil.org) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | This module is released under the terms of the Artistic License 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | For details, see the full text of the license in the file LICENSE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||