line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Font::TTF::Maxp; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Font::TTF::Maxp - Maximum Profile table in a font |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A collection of useful instance variables following the TTF standard. Probably |
10
|
|
|
|
|
|
|
the most used being C. Note that this particular value is |
11
|
|
|
|
|
|
|
foundational and should be kept up to date by the application, it is not updated |
12
|
|
|
|
|
|
|
by C. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Handles table versions 0.5, 1.0 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 INSTANCE VARIABLES |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
No others beyond those specified in the standard: |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
numGlyphs |
21
|
|
|
|
|
|
|
maxPoints |
22
|
|
|
|
|
|
|
maxContours |
23
|
|
|
|
|
|
|
maxCompositePoints |
24
|
|
|
|
|
|
|
maxCompositeContours |
25
|
|
|
|
|
|
|
maxZones |
26
|
|
|
|
|
|
|
maxTwilightPoints |
27
|
|
|
|
|
|
|
maxStorage |
28
|
|
|
|
|
|
|
maxFunctionDefs |
29
|
|
|
|
|
|
|
maxInstructionDefs |
30
|
|
|
|
|
|
|
maxStackElements |
31
|
|
|
|
|
|
|
maxSizeOfInstructions |
32
|
|
|
|
|
|
|
maxComponentElements |
33
|
|
|
|
|
|
|
maxComponentDepth |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
41
|
1
|
|
|
1
|
|
3
|
use vars qw(@ISA %fields @field_info); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
42
|
1
|
|
|
1
|
|
3
|
use Font::TTF::Utils; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
492
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
@ISA = qw(Font::TTF::Table); |
45
|
|
|
|
|
|
|
@field_info = ( |
46
|
|
|
|
|
|
|
'numGlyphs' => 'S', |
47
|
|
|
|
|
|
|
'maxPoints' => 'S', |
48
|
|
|
|
|
|
|
'maxContours' => 'S', |
49
|
|
|
|
|
|
|
'maxCompositePoints' => 'S', |
50
|
|
|
|
|
|
|
'maxCompositeContours' => 'S', |
51
|
|
|
|
|
|
|
'maxZones' => 'S', |
52
|
|
|
|
|
|
|
'maxTwilightPoints' => 'S', |
53
|
|
|
|
|
|
|
'maxStorage' => 'S', |
54
|
|
|
|
|
|
|
'maxFunctionDefs' => 'S', |
55
|
|
|
|
|
|
|
'maxInstructionDefs' => 'S', |
56
|
|
|
|
|
|
|
'maxStackElements' => 'S', |
57
|
|
|
|
|
|
|
'maxSizeOfInstructions' => 'S', |
58
|
|
|
|
|
|
|
'maxComponentElements' => 'S', |
59
|
|
|
|
|
|
|
'maxComponentDepth' => 'S'); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub init |
62
|
|
|
|
|
|
|
{ |
63
|
1
|
|
|
1
|
0
|
1
|
my ($k, $v, $c, $i); |
64
|
1
|
|
|
|
|
3
|
for ($i = 0; $i < $#field_info; $i += 2) |
65
|
|
|
|
|
|
|
{ |
66
|
14
|
|
|
|
|
21
|
($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]); |
67
|
14
|
50
|
33
|
|
|
41
|
next unless defined $k && $k ne ""; |
68
|
14
|
|
|
|
|
34
|
$fields{$k} = $v; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 $t->read |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Reads the table into memory |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub read |
80
|
|
|
|
|
|
|
{ |
81
|
4
|
|
|
4
|
1
|
8
|
my ($self) = @_; |
82
|
4
|
|
|
|
|
3
|
my ($dat); |
83
|
|
|
|
|
|
|
|
84
|
4
|
100
|
|
|
|
11
|
$self->SUPER::read or return $self; |
85
|
|
|
|
|
|
|
|
86
|
2
|
100
|
|
|
|
10
|
init unless defined $fields{'numGlyphs'}; # any key would do |
87
|
2
|
|
|
|
|
5
|
$self->{' INFILE'}->read($dat, 4); |
88
|
2
|
|
|
|
|
18
|
$self->{'version'} = TTF_Unpack("v", $dat); |
89
|
|
|
|
|
|
|
|
90
|
2
|
50
|
|
|
|
8
|
if ($self->{'version'} == 0.5) |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
|
|
0
|
$self->{' INFILE'}->read($dat, 2); |
93
|
0
|
|
|
|
|
0
|
$self->{'numGlyphs'} = unpack("n", $dat); |
94
|
|
|
|
|
|
|
} else |
95
|
|
|
|
|
|
|
{ |
96
|
2
|
|
|
|
|
4
|
$self->{' INFILE'}->read($dat, 28); |
97
|
2
|
|
|
|
|
11
|
TTF_Read_Fields($self, $dat, \%fields); |
98
|
|
|
|
|
|
|
} |
99
|
2
|
|
|
|
|
5
|
$self; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 $t->out($fh) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Writes the table to a file either from memory or by copying. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub out |
110
|
|
|
|
|
|
|
{ |
111
|
2
|
|
|
2
|
1
|
3
|
my ($self, $fh) = @_; |
112
|
|
|
|
|
|
|
|
113
|
2
|
50
|
|
|
|
6
|
return $self->SUPER::out($fh) unless $self->{' read'}; |
114
|
2
|
|
|
|
|
10
|
$fh->print(TTF_Pack("v", $self->{'version'})); |
115
|
|
|
|
|
|
|
|
116
|
2
|
50
|
|
|
|
11
|
if ($self->{'version'} == 0.5) |
117
|
0
|
|
|
|
|
0
|
{ $fh->print(pack("n", $self->{'numGlyphs'})); } |
118
|
|
|
|
|
|
|
else |
119
|
2
|
|
|
|
|
6
|
{ $fh->print(TTF_Out_Fields($self, \%fields, 28)); } |
120
|
2
|
|
|
|
|
9
|
$self; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 $t->minsize() |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns the minimum size this table can be. If it is smaller than this, then the table |
126
|
|
|
|
|
|
|
must be bad and should be deleted or whatever. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub minsize |
131
|
|
|
|
|
|
|
{ |
132
|
0
|
|
|
0
|
1
|
|
return 4; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 $t->update |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Calculates all the maximum values for a font based on the glyphs in the font. |
139
|
|
|
|
|
|
|
Only those fields which require hinting code interpretation are ignored and |
140
|
|
|
|
|
|
|
left as they were read. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub update |
145
|
|
|
|
|
|
|
{ |
146
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
147
|
0
|
|
|
|
|
|
my ($i, $num, @n, @m, $j); |
148
|
0
|
|
|
|
|
|
my (@name) = qw(maxPoints maxContours maxCompositePoints maxCompositeContours |
149
|
|
|
|
|
|
|
maxSizeOfInstructions maxComponentElements maxComponentDepth); |
150
|
|
|
|
|
|
|
|
151
|
0
|
0
|
|
|
|
|
return undef unless ($self->SUPER::update); |
152
|
0
|
0
|
|
|
|
|
return undef if ($self->{'version'} == 0.5); # only got numGlyphs |
153
|
0
|
0
|
|
|
|
|
return undef unless (defined $self->{' PARENT'}{'loca'}); |
154
|
0
|
|
|
|
|
|
$self->{' PARENT'}{'loca'}->update; |
155
|
0
|
|
|
|
|
|
$num = $self->{'numGlyphs'}; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
for ($i = 0; $i < $num; $i++) |
158
|
|
|
|
|
|
|
{ |
159
|
0
|
|
0
|
|
|
|
my ($g) = $self->{' PARENT'}{'loca'}{'glyphs'}[$i] || next; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
@n = $g->maxInfo; |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
for ($j = 0; $j <= $#n; $j++) |
164
|
0
|
0
|
|
|
|
|
{ $m[$j] = $n[$j] if $n[$j] > $m[$j]; } |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
foreach ('prep', 'fpgm') |
168
|
|
|
|
|
|
|
{ $m[4] = length($self->{' PARENT'}{$_}{' dat'}) |
169
|
|
|
|
|
|
|
if (defined $self->{' PARENT'}{$_} |
170
|
0
|
0
|
0
|
|
|
|
&& length($self->{' PARENT'}{$_}{' dat'}) > $m[4]); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
for ($j = 0; $j <= $#name; $j++) |
174
|
0
|
|
|
|
|
|
{ $self->{$name[$j]} = $m[$j]; } |
175
|
0
|
|
|
|
|
|
$self; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 BUGS |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
None known |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Martin Hosken L. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 LICENSING |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Copyright (c) 1998-2016, SIL International (http://www.sil.org) |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This module is released under the terms of the Artistic License 2.0. |
194
|
|
|
|
|
|
|
For details, see the full text of the license in the file LICENSE. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|