| 1 | package Font::TTF::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Font::TTF::Utils - Utility functions to save fingers | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | Lots of useful functions to save my fingers, especially for trivial tables | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | The following functions are exported | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use vars qw(@ISA @EXPORT $VERSION @EXPORT_OK); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | @EXPORT = qw(TTF_Init_Fields TTF_Read_Fields TTF_Out_Fields TTF_Pack | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | TTF_Unpack TTF_word_utf8 TTF_utf8_word TTF_bininfo); | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | @EXPORT_OK = (@EXPORT, qw(XML_hexdump)); | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | $VERSION = 0.0001; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =head2 ($val, $pos) = TTF_Init_Fields ($str, $pos) | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | Given a field description from the C<DATA> section, creates an absolute entry | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | in the fields associative array for the class | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | sub TTF_Init_Fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 119 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_Init_Fields: called CC=18 SCAR=30.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 119 | my ($str, $pos, $inval) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 119 | my ($key, $val, $res, $len, $rel); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 119 | $str =~ s/\r?\n$//o; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 119 | ▶ | if ($inval) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 119 | { ($key, $val) = ($str, $inval); } | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | { ($key, $val) = split(',\s*', $str); } | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 119 | ▶ | return (undef, undef, 0) unless (defined $key && $key ne ""); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $key and $key ne ""
MC/DC0%0/2
defined $key and $key ne ""
defined $key
$key ne ""
Truth table33%1/3
A and B
A= defined $keyB= $key ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 119 | ▶ | if ($val =~ m/^(\+?)(\d*)(\D+)(\d*)/oi) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 119 | $rel = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 119 | ▶ | if ($rel eq "+") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | { $pos += $2; } | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | elsif ($2 ne "") | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | { $pos = $2; } | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 119 | $val = $3; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 119 | $len = $4; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 119 | ▶ | $len = "" unless defined $len; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 119 | ▶ | $pos = 0 if !defined $pos || $pos eq ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $pos or $pos eq ""
MC/DC50%1/2
not defined $pos or $pos eq ""
not defined $pos
$pos eq ""
Truth table66%2/3
not(A) or B
A= not defined $posB= $pos eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 119 | $res = "$pos:$val:$len"; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 119 | ▶ | if ($val eq "f" || $val eq 'v' || $val =~ m/^[l]/oi) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
$val eq "f" or $val eq "v" or $val =~ /^[l]/io
$val eq "f" or $val eq "v"
MC/DC100%3/3
$val eq "f" or $val eq "v" or $val =~ /^[l]/io
$val eq "f"
$val eq "v"
$val =~ /^[l]/io
Truth table100%4/4
A or B or C
A= $val eq "f"B= $val eq "v"C= $val =~ /^[l]/io
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 27 | ▶ | { $pos += 4 * ($len ne "" ? $len : 1); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ▶ | elsif ($val eq "F" || $val =~ m/^[s]/oi) | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$val eq "F" or $val =~ /^[s]/io
MC/DC50%1/2
$val eq "F" or $val =~ /^[s]/io
$val eq "F"
$val =~ /^[s]/io
Truth table66%2/3
A or B
A= $val eq "F"B= $val =~ /^[s]/io
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 82 | ▶ | { $pos += 2 * ($len ne "" ? $len : 1); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 10 | ▶ | { $pos += 1 * ($len ne "" ? $len : 1); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 119 | ($key, $res, $pos); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =head2 TTF_Read_Fields($obj, $dat, $fields) | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | Given a block of data large enough to account for all the fields in a table, | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | processes the data block to convert to the values in the objects instance | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | variables by name based on the list in the C<DATA> block which has been run | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | through C<TTF_Init_Fields> | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | sub TTF_Read_Fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 198 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_Read_Fields: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 198 | my ($self, $dat, $fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 198 | my ($pos, $type, $res, $f, $arrlen, $arr, $frac); | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 198 | foreach $f (keys %{$fields}) | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1134 | ($pos, $type, $arrlen) = split(':', $fields->{$f}); | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1134 | ▶ | $pos = 0 if $pos eq ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1134 | ▶ | if ($arrlen ne "") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | { $self->{$f} = [TTF_Unpack("$type$arrlen", substr($dat, $pos))]; } | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1130 | { $self->{$f} = TTF_Unpack("$type", substr($dat, $pos)); } | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 198 | $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head2 TTF_Unpack($fmt, $dat) | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | A TrueType types equivalent of Perls C<unpack> function. Thus $fmt consists of | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | type followed by an optional number of elements to read including *. The type | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | may be one of: | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | c BYTE | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | C CHAR | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | f FIXED | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | F F2DOT14 | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | l LONG | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | L ULONG | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | s SHORT | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | S USHORT | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | v Version number (FIXED) | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | Note that C<FUNIT>, C<FWORD> and C<UFWORD> are not data types but units. | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | Returns array of scalar (first element) depending on context | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | sub TTF_Unpack | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2302 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_Unpack: called CC=21 SCAR=32.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2302 | my ($fmt, $dat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 2302 | my ($res, $frac, $i, $arrlen, $type, @res); | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2302 | ▶ | while ($fmt =~ s/^([cflsv])(\d+|\*)?//oi) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2302 | $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2302 | $arrlen = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2302 | ▶ | $arrlen = 1 if !defined $arrlen || $arrlen eq ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $arrlen or $arrlen eq ""
MC/DC50%1/2
not defined $arrlen or $arrlen eq ""
not defined $arrlen
$arrlen eq ""
Truth table66%2/3
not(A) or B
A= not defined $arrlenB= $arrlen eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2302 | ▶ | $arrlen = -1 if $arrlen eq "*"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2302 | ▶ | for ($i = 0; ($arrlen == -1 && $dat ne "") || $i < $arrlen; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$arrlen == -1 and $dat ne "" or $i < $arrlen
$arrlen == -1 and $dat ne ""
MC/DC100%3/3
$arrlen == -1 and $dat ne "" or $i < $arrlen
$arrlen == -1
$dat ne ""
$i < $arrlen
Truth table80%4/5
A and B or C
A= $arrlen == -1B= $dat ne ""C= $i < $arrlen
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2334 | ▶ | if ($type eq "f") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | ($res, $frac) = unpack("nn", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | substr($dat, 0, 4) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | ▶ | $res -= 65536 if $res > 32767; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 6 | $res += $frac / 65536.; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | elsif ($type eq "v") | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 6 | ($res, $frac) = unpack("nn", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 6 | substr($dat, 0, 4) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 6 | $res = sprintf("%d.%04X", $res, $frac); | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | elsif ($type eq "F") | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $res = unpack("n", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | substr($dat, 0, 2) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | # $res -= 65536 if $res >= 32768; | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $frac = $res & 0x3fff; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $res >>= 14; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $res -= 4 if $res > 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # $frac -= 16384 if $frac > 8191; | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $res += $frac / 16384.; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | elsif ($type =~ m/^[l]/oi) | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 36 | $res = unpack("N", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 36 | substr($dat, 0, 4) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 36 | ▶ | $res -= (1 << 32) if ($type eq "l" && $res >= 1 << 31); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "l" and $res >= 2147483648
MC/DC0%0/2
$type eq "l" and $res >= 2147483648
$type eq "l"
$res >= 2147483648
Truth table33%1/3
A and B
A= $type eq "l"B= $res >= 2147483648
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | elsif ($type =~ m/^[s]/oi) | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2266 | $res = unpack("n", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2266 | substr($dat, 0, 2) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2266 | ▶ | $res -= 65536 if ($type eq "s" && $res >= 32768); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type eq "s" and $res >= 32768
MC/DC100%2/2
$type eq "s" and $res >= 32768
$type eq "s"
$res >= 32768
Truth table100%3/3
A and B
A= $type eq "s"B= $res >= 32768
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | elsif ($type eq "c") | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $res = unpack("c", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | substr($dat, 0, 1) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 20 | $res = unpack("C", $dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 20 | substr($dat, 0, 1) = ""; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2334 | push (@res, $res); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2302 | ▶ | return wantarray ? @res : $res[0]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | =head2 $dat = TTF_Out_Fields($obj, $fields, $len) | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | Given the fields table from C<TTF_Init_Fields> writes out the instance variables from | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | the object to the filehandle in TTF binary form. | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | sub TTF_Out_Fields | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_Out_Fields: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 10 | my ($obj, $fields, $len) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | 10 | my ($dat) = "\000" x $len; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 10 | my ($f, $pos, $type, $res, $arr, $arrlen, $frac); | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 10 | foreach $f (keys %{$fields}) | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 194 | ($pos, $type, $arrlen) = split(':', $fields->{$f}); | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 194 | ▶ | if ($arrlen ne "") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | { $res = TTF_Pack("$type$arrlen", @{$obj->{$f}}); } | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 190 | { $res = TTF_Pack("$type", $obj->{$f}); } | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 194 | substr($dat, $pos, length($res)) = $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | $dat; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | =head2 $dat = TTF_Pack($fmt, @data) | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | The TrueType equivalent to Perl's C<pack> function. See details of C<TTF_Unpack> | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | for how to work the $fmt string. | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | sub TTF_Pack | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 196 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_Pack: called CC=18 SCAR=30.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 196 | my ($fmt, @obj) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | 196 | my ($type, $i, $arrlen, $dat, $res, $frac); | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 196 | $dat = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 196 | ▶ | while ($fmt =~ s/^([flscv])(\d+|\*)?//oi) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 196 | $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 196 | ▶ | $arrlen = $2 || ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$2 || ''
MC/DC100%1/1
$2 || ''
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 196 | ▶ | $arrlen = $#obj + 1 if $arrlen eq "*"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 196 | ▶ | $arrlen = 1 if $arrlen eq ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 196 | ▶ | for ($i = 0; $i < $arrlen; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 200 | ▶ | $res = shift(@obj) || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @obj || 0
MC/DC100%1/1
shift @obj || 0
shift @obj
Truth table100%2/2
A
A= shift @obj
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 200 | ▶ | if ($type eq "f") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 6 | $frac = int(($res - int($res)) * 65536); | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | 6 | $res = (int($res) << 16) + $frac; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 6 | $dat .= pack("N", $res); | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | elsif ($type eq "v") | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 6 | ▶ | if ($res =~ s/\.([0-9a-f]+)$//oi) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 6 | $frac = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | $frac .= "0" x (4 - length($frac)); | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | { $frac = 0; } | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | $dat .= pack('nn', $res, hex($frac)); | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | elsif ($type eq "F") | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $frac = int(($res - int($res)) * 16384); | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $res = (int($res) << 14) + $frac; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $dat .= pack("n", $res); | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | elsif ($type =~ m/^[l]/oi) | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 36 | ▶ | $res += 1 << 32 if ($type eq 'L' && $res < 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type eq "L" and $res < 0
MC/DC0%0/2
$type eq "L" and $res < 0
$type eq "L"
$res < 0
Truth table33%1/3
A and B
A= $type eq "L"B= $res < 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 36 | $dat .= pack("N", $res); | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | elsif ($type =~ m/^[s]/oi) | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 132 | ▶ | $res += 1 << 16 if ($type eq 'S' && $res < 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type eq "S" and $res < 0
MC/DC0%0/2
$type eq "S" and $res < 0
$type eq "S"
$res < 0
Truth table66%2/3
A and B
A= $type eq "S"B= $res < 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 132 | $dat .= pack("n", $res); | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | elsif ($type eq "c") | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | { $dat .= pack("c", $res); } | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 20 | { $dat .= pack("C", $res); } | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 196 | $dat; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | =head2 ($num, $range, $select, $shift) = TTF_bininfo($num) | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | Calculates binary search information from a number of elements | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | sub TTF_bininfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_bininfo: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 6 | my ($num, $block) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | my ($range, $select, $shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6 | $range = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6 | ▶ | for ($select = 0; $range <= $num; $select++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 16 | { $range *= 2; } | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 6 | $select--; $range /= 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | 6 | $range *= $block; | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 6 | $shift = $num * $block - $range; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | 6 | ($num, $range, $select, $shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | =head2 TTF_word_utf8($str) | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | Returns the UTF8 form of the 16 bit string, assumed to be in big endian order, | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | including surrogate handling | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | sub TTF_word_utf8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 122 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_word_utf8: called CC=7 SCAR=35.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 122 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | 122 | my ($res, $i); | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | 122 | my (@dat) = unpack("n*", $str); | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 122 | ▶ | return pack("U*", @dat) if ($] >= 5.006); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | for ($i = 0; $i <= $#dat; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my ($dat) = $dat[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if ($dat < 0x80) # Thanks to Gisle Aas for some of his old code | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | { $res .= chr($dat); } | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | elsif ($dat < 0x800) | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | { $res .= chr(0xC0 | ($dat >> 6)) . chr(0x80 | ($dat & 0x3F)); } | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | ▶ | elsif ($dat >= 0xD800 && $dat < 0xDC00) | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$dat >= 55296 and $dat < 56320
MC/DC0%0/2
$dat >= 55296 and $dat < 56320
$dat >= 55296
$dat < 56320
Truth table0%0/3
A and B
A= $dat >= 55296B= $dat < 56320
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my ($dat1) = $dat[++$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my ($top) = (($dat & 0x3C0) >> 6) + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $res .= chr(0xF0 | ($top >> 2)) | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | . chr(0x80 | (($top & 1) << 4) | (($dat & 0x3C) >> 2)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | . chr(0x80 | (($dat & 0x3) << 4) | (($dat1 & 0x3C0) >> 6)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | . chr(0x80 | ($dat1 & 0x3F)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } else | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | { $res .= chr(0xE0 | ($dat >> 12)) . chr(0x80 | (($dat >> 6) & 0x3F)) | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | . chr(0x80 | ($dat & 0x3F)); } | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | =head2 TTF_utf8_word($str) | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | Returns the 16-bit form in big endian order of the UTF 8 string, including | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | surrogate handling to Unicode. | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | sub TTF_utf8_word | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 122 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TTF_utf8_word: called CC=8 SCAR=38.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 122 | my ($str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 346 | 122 | my ($res); | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 122 | ▶ | return pack("n*", unpack("U*", $str)) if ($^V ge v5.6.0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $str = "$str"; # copy $str | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | while (length($str)) # Thanks to Gisle Aas for some of his old code | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $str =~ s/^[\x80-\xBF]+//o; | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ($str =~ s/^([\x00-\x7F]+)//o) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | { $res .= pack("n*", unpack("C*", $1)); } | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | elsif ($str =~ s/^([\xC0-\xDF])([\x80-\xBF])//o) | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | { $res .= pack("n", ((ord($1) & 0x1F) << 6) | (ord($2) & 0x3F)); } | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | elsif ($str =~ s/^([\0xE0-\xEF])([\x80-\xBF])([\x80-\xBF])//o) | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | { $res .= pack("n", ((ord($1) & 0x0F) << 12) | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | | ((ord($2) & 0x3F) << 6) | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | | (ord($3) & 0x3F)); } | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | elsif ($str =~ s/^([\xF0-\xF7])([\x80-\xBF])([\x80-\xBF])([\x80-\xBF])//o) | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my ($b1, $b2, $b3, $b4) = (ord($1), ord($2), ord($3), ord($4)); | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $res .= pack("n", ((($b1 & 0x07) << 8) | (($b2 & 0x3F) << 2) | |||||||||||||||||||||||||||||||||||||||||||||
| 365 | | (($b3 & 0x30) >> 4)) + 0xD600); # account for offset | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $res .= pack("n", ((($b3 & 0x0F) << 6) | ($b4 & 0x3F)) + 0xDC00); | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | elsif ($str =~ s/^[\xF8-\xFF][\x80-\xBF]*//o) | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | { } | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | =head2 XML_hexdump($context, $dat) | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Dumps out the given data as a sequence of <data> blocks each 16 bytes wide | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | sub XML_hexdump | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XML_hexdump: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my ($context, $depth, $dat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my ($fh) = $context->{'fh'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my ($i, $len, $out); | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $len = length($dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | for ($i = 0; $i < $len; $i += 16) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $out = join(' ', map {sprintf("%02X", ord($_))} (split('', substr($dat, $i, 16)))); | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $fh->printf("%s<data addr='%04X'>%s</data>\n", $depth, $i, $out); | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | =head2 XML_outhints | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | Converts a binary string of hinting code into a textual representation | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my (@hints) = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | ['SVTCA[0]'], ['SVTCA[1]'], ['SPVTCA[0]'], ['SPVTCA[1]'], ['SFVTCA[0]'], ['SFVTCA[1]'], ['SPVTL[0]'], ['SPVTL[1]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 405 | ['SFVTL[0]'], ['SFVTL[1]'], ['SPVFS'], ['SFVFS'], ['GPV'], ['GFV'], ['SVFTPV'], ['ISECT'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # 10 | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ['SRP0'], ['SRP1'], ['SRP2'], ['SZP0'], ['SZP1'], ['SZP2'], ['SZPS'], ['SLOOP'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ['RTG'], ['RTHG'], ['SMD'], ['ELSE'], ['JMPR'], ['SCVTCI'], ['SSWCI'], ['SSW'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # 20 | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | ['DUP'], ['POP'], ['CLEAR'], ['SWAP'], ['DEPTH'], ['CINDEX'], ['MINDEX'], ['ALIGNPTS'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | [], ['UTP'], ['LOOPCALL'], ['CALL'], ['FDEF'], ['ENDF'], ['MDAP[0]'], ['MDAP[1]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # 30 | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ['IUP[0]'], ['IUP[1]'], ['SHP[0]'], ['SHP[1]'], ['SHC[0]'], ['SHC[1]'], ['SHZ[0]'], ['SHZ[1]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ['SHPIX'], ['IP'], ['MSIRP[0]'], ['MSIRP[1]'], ['ALIGNRP'], ['RTDG'], ['MIAP[0]'], ['MIAP[1]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # 40 | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ['NPUSHB', -1, 1], ['NPUSHW', -1, 2], ['WS', 0, 0], ['RS', 0, 0], ['WCVTP', 0, 0], ['RCVT', 0, 0], ['GC[0]'], ['GC[1]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | ['SCFS'], ['MD[0]'], ['MD[1]'], ['MPPEM'], ['MPS'], ['FLIPON'], ['FLIPOFF'], ['DEBUG'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # 50 | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ['LT'], ['LTEQ'], ['GT'], ['GTEQ'], ['EQ'], ['NEQ'], ['ODD'], ['EVEN'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ['IF'], ['EIF'], ['AND'], ['OR'], ['NOT'], ['DELTAP1'], ['SDB'], ['SDS'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # 60 | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ['ADD'], ['SUB'], ['DIV'], ['MULT'], ['ABS'], ['NEG'], ['FLOOR'], ['CEILING'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ['ROUND[0]'], ['ROUND[1]'], ['ROUND[2]'], ['ROUND[3]'], ['NROUND[0]'], ['NROUND[1]'], ['NROUND[2]'], ['NROUND[3]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # 70 | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ['WCVTF'], ['DELTAP2'], ['DELTAP3'], ['DELTAC1'], ['DELTAC2'], ['DELTAC3'], ['SROUND'], ['S45ROUND'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ['JROT'], ['JROF'], ['ROFF'], [], ['RUTG'], ['RDTG'], ['SANGW'], [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # 80 | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | ['FLIPPT'], ['FLIPRGON'], ['FLIPRGOFF'], [], [], ['SCANCTRL'], ['SDPVTL[0]'], ['SDPVTL[1]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ['GETINFO'], ['IDEF'], ['ROLL'], ['MAX'], ['MIN'], ['SCANTYPE'], ['INSTCTRL'], [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # 90 | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # A0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # B0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ['PUSHB1', 1, 1], ['PUSHB2', 2, 1], ['PUSHB3', 3, 1], ['PUSHB4', 4, 1], ['PUSHB5', 5, 1], ['PUSHB6', 6, 1], ['PUSHB7', 7, 1], ['PUSHB8', 8, 1], | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ['PUSHW1', 1, 2], ['PUSHW2', 2, 2], ['PUSHW3', 3, 2], ['PUSHW4', 4, 2], ['PUSHW5', 5, 2], ['PUSHW6', 6, 2], ['PUSHW7', 7, 2], ['PUSHW8', 8, 2], | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # C0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ['MDRP[0]'], ['MDRP[1]'], ['MDRP[2]'], ['MDRP[3]'], ['MDRP[4]'], ['MDRP[5]'], ['MDRP[6]'], ['MDRP[7]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | ['MDRP[8]'], ['MDRP[9]'], ['MDRP[A]'], ['MDRP[B]'], ['MDRP[C]'], ['MDRP[D]'], ['MDRP[E]'], ['MDRP[F]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # D0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ['MDRP[10]'], ['MDRP[11]'], ['MDRP[12]'], ['MDRP[13]'], ['MDRP[14]'], ['MDRP[15]'], ['MDRP[16]'], ['MDRP[17]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | ['MDRP[18]'], ['MDRP[19]'], ['MDRP[1A]'], ['MDRP[1B]'], ['MDRP[1C]'], ['MDRP[1D]'], ['MDRP[1E]'], ['MDRP[1F]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # E0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ['MIRP[0]'], ['MIRP[1]'], ['MIRP[2]'], ['MIRP[3]'], ['MIRP[4]'], ['MIRP[5]'], ['MIRP[6]'], ['MIRP[7]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ['MIRP[8]'], ['MIRP[9]'], ['MIRP[A]'], ['MIRP[B]'], ['MIRP[C]'], ['MIRP[D]'], ['MIRP[E]'], ['MIRP[F]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # F0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | ['MIRP[10]'], ['MIRP[11]'], ['MIRP[12]'], ['MIRP[13]'], ['MIRP[14]'], ['MIRP[15]'], ['MIRP[16]'], ['MIRP[17]'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ['MIRP[18]'], ['MIRP[19]'], ['MIRP[1A]'], ['MIRP[1B]'], ['MIRP[1C]'], ['MIRP[1D]'], ['MIRP[1E]'], ['MIRP[1F]']); | ||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | my ($i); | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | ▶ | my (%hints) = map { $_->[0] => $i++ if (defined $_->[0]); } @hints; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | sub XML_binhint | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XML_binhint: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my ($dat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my ($len) = length($dat); | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my ($res, $i, $text, $size, $num); | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | for ($i = 0; $i < $len; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ($text, $num, $size) = @{$hints[ord(substr($dat, $i, 1))]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | $num = 0 unless (defined $num); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $text = sprintf("UNK[%02X]", ord(substr($dat, $i, 1))) unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $res .= $text; | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if ($num != 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($num < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | my ($nnum) = unpack($num == -1 ? 'C' : 'n', substr($dat, $i, -$num)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $i += -$num - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $num = $nnum; | |||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | $res .= "\t" . join(' ', unpack($size == 1 ? 'C*' : 'n*', substr($dat, $i + 1, $num * $size))); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $i += $num * $size; | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $res .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | sub XML_hintbin | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XML_hintbin: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my ($dat) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my ($l, $res, @words, $num); | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | foreach $l (split(/\s*\n\s*/, $dat)) | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | @words = split(/\s*/, $l); | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | next unless (defined $hints{$words[0]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $num = $hints{$words[0]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $res .= pack('C', $num); | |||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if ($hints[$num][1] < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | $res .= pack($hints[$num][1] == -1 ? 'C' : 'n', $#words); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | $res .= pack($hints[$num][2] == 1 ? 'C*' : 'n*', @words[1 .. $#words]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | elsif ($hints[$num][1] > 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | $res .= pack($hints[$num][2] == 1 ? 'C*' : 'n*', @words[1 .. $hints[$num][1]]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | =head2 make_circle($f, $cmap, [$dia, $sb, $opts]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | Adds a dotted circle to a font. This function is very configurable. The | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | parameters passed in are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | =item $f | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||
| 517 | Font to work with. This is required. | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | =item $cmap | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | A cmap table (not the 'val' sub-element of a cmap) to add the glyph too. Optional. | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | =item $dia | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | Optional diameter for the main circle. Defaults to 80% em | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | =item $sb | ||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | Side bearing. The left and right side-bearings are always the same. This value | ||||||||||||||||||||||||||||||||||||||||||||||
| 530 | defaults to 10% em. | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | There are various options to control all sorts of interesting aspects of the circle | ||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||
| 536 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | =item numDots | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | Number of dots in the circle | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | =item numPoints | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | Number of curve points to use to create each dot | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | =item uid | ||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||
| 548 | Unicode reference to store this glyph under in the cmap. Defaults to 0x25CC | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | =item pname | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||
| 552 | Postscript name to give the glyph. Defaults to uni25CC. | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | =item -dRadius | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | Radius of each dot. | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | sub make_circle | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_circle: not called CC=14 SCAR=53.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my ($font, $cmap, $dia, $sb, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my ($upem) = $font->{'head'}{'unitsPerEm'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my ($glyph) = Font::TTF::Glyph->new('PARENT' => $font, 'read' => 2, 'isDirty' => 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my ($PI) = 3.1415926535; | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my ($R, $r, $xorg, $yorg); | |||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | my ($i, $j, $numg, $maxp); | |||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | my ($numc) = $opts{'-numDots'} || 16; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'-numDots'} || 16
MC/DC0%0/1
$opts{'-numDots'} || 16
$opts{'-numDots'}
Truth table0%0/2
A
A= $opts{'-numDots'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | my ($nump) = ($opts{'-numPoints'} * 2) || 8; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'-numPoints'} * 2 || 8
MC/DC0%0/1
$opts{'-numPoints'} * 2 || 8
$opts{'-numPoints'} * 2
Truth table0%0/2
A
A= $opts{'-numPoints'} * 2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | my ($uid) = $opts{'-uid'} || 0x25CC; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'-uid'} || 9676
MC/DC0%0/1
$opts{'-uid'} || 9676
$opts{'-uid'}
Truth table0%0/2
A
A= $opts{'-uid'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | my ($pname) = $opts{'-pname'} || 'uni25CC'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'-pname'} || 'uni25CC'
MC/DC0%0/1
$opts{'-pname'} || 'uni25CC'
$opts{'-pname'}
Truth table0%0/2
A
A= $opts{'-pname'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | $dia ||= $upem * .8; # .95 to fit exactly | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$dia ||= $upem * "0.8"
MC/DC0%0/2
$dia ||= $upem * "0.8"
$dia
$upem * "0.8"
Truth table0%0/3
A ||= B
A= $diaB= $upem * "0.8"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | $sb ||= $upem * .1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sb ||= $upem * "0.1"
MC/DC0%0/2
$sb ||= $upem * "0.1"
$sb
$upem * "0.1"
Truth table0%0/3
A ||= B
A= $sbB= $upem * "0.1"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $R = $dia / 2; | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | $r = $opts{'-dRadius'} || ($R * .1); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{'-dRadius'} || $R * 0.1
MC/DC0%0/2
$opts{'-dRadius'} || $R * 0.1
$opts{'-dRadius'}
$R * 0.1
Truth table0%0/3
A || B
A= $opts{'-dRadius'}B= $R * 0.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ($xorg, $yorg) = ($R + $r, $R); | |||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $xorg += $sb; | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $font->{'post'}->read; | |||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $font->{'glyf'}->read; | |||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | for ($i = 0; $i < $numc; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 585 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my ($pxorg, $pyorg) = ($xorg + $R * cos(2 * $PI * $i / $numc), | |||||||||||||||||||||||||||||||||||||||||||||
| 587 | $yorg + $R * sin(2 * $PI * $i / $numc)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | for ($j = 0; $j < $nump; $j++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | push (@{$glyph->{'x'}}, int ($pxorg + ($j & 1 ? 1/cos(2*$PI/$nump) : 1) * $r * cos(2 * $PI * $j / $nump))); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | push (@{$glyph->{'y'}}, int ($pyorg + ($j & 1 ? 1/cos(2*$PI/$nump) : 1) * $r * sin(2 * $PI * $j / $nump))); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | push (@{$glyph->{'flags'}}, $j & 1 ? 0 : 1); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | push (@{$glyph->{'endPoints'}}, $#{$glyph->{'x'}}); | |||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $glyph->{'numberOfContours'} = $#{$glyph->{'endPoints'}} + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $glyph->{'numPoints'} = $#{$glyph->{'x'}} + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $glyph->update; | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $numg = $font->{'maxp'}{'numGlyphs'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $font->{'maxp'}{'numGlyphs'}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $font->{'hmtx'}{'advance'}[$numg] = int($xorg + $R + $r + $sb + .5); | |||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $font->{'hmtx'}{'lsb'}[$numg] = int($xorg - $R - $r + .5); | |||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $font->{'loca'}{'glyphs'}[$numg] = $glyph; | |||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | $cmap->{'val'}{$uid} = $numg if ($cmap); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $font->{'post'}{'VAL'}[$numg] = $pname; | |||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | delete $font->{'hdmx'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | delete $font->{'VDMX'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | delete $font->{'LTSH'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | $font->tables_do(sub {$_[0]->dirty;}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $font->update; | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | return ($numg - 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | No known bugs | ||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | Martin Hosken L<http://scripts.sil.org/FontUtils>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | =head1 LICENSING | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||
| 630 | Copyright (c) 1998-2016, SIL International (http://www.sil.org) | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||
| 632 | This module is released under the terms of the Artistic License 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | For details, see the full text of the license in the file LICENSE. | ||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||