line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Font::TTF::Hhea; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Font::TTF::Hhea - Horizontal Header table |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This is a simplte table with just standards specified instance variables |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 INSTANCE VARIABLES |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
version |
14
|
|
|
|
|
|
|
Ascender |
15
|
|
|
|
|
|
|
Descender |
16
|
|
|
|
|
|
|
LineGap |
17
|
|
|
|
|
|
|
advanceWidthMax |
18
|
|
|
|
|
|
|
minLeftSideBearing |
19
|
|
|
|
|
|
|
minRightSideBearing |
20
|
|
|
|
|
|
|
xMaxExtent |
21
|
|
|
|
|
|
|
caretSlopeRise |
22
|
|
|
|
|
|
|
caretSlopeRun |
23
|
|
|
|
|
|
|
metricDataFormat |
24
|
|
|
|
|
|
|
numberOfHMetrics |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
32
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA %fields @field_info); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
require Font::TTF::Table; |
35
|
1
|
|
|
1
|
|
4
|
use Font::TTF::Utils; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
512
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
@ISA = qw(Font::TTF::Table); |
38
|
|
|
|
|
|
|
@field_info = ( |
39
|
|
|
|
|
|
|
'version' => 'v', |
40
|
|
|
|
|
|
|
'Ascender' => 's', |
41
|
|
|
|
|
|
|
'Descender' => 's', |
42
|
|
|
|
|
|
|
'LineGap' => 's', |
43
|
|
|
|
|
|
|
'advanceWidthMax' => 'S', |
44
|
|
|
|
|
|
|
'minLeftSideBearing' => 's', |
45
|
|
|
|
|
|
|
'minRightSideBearing' => 's', |
46
|
|
|
|
|
|
|
'xMaxExtent' => 's', |
47
|
|
|
|
|
|
|
'caretSlopeRise' => 's', |
48
|
|
|
|
|
|
|
'caretSlopeRun' => 's', |
49
|
|
|
|
|
|
|
'metricDataFormat' => '+10s', |
50
|
|
|
|
|
|
|
'numberOfHMetrics' => 'S'); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub init |
53
|
|
|
|
|
|
|
{ |
54
|
1
|
|
|
1
|
0
|
1
|
my ($k, $v, $c, $i); |
55
|
1
|
|
|
|
|
4
|
for ($i = 0; $i < $#field_info; $i += 2) |
56
|
|
|
|
|
|
|
{ |
57
|
12
|
|
|
|
|
41
|
($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]); |
58
|
12
|
50
|
33
|
|
|
56
|
next unless defined $k && $k ne ""; |
59
|
12
|
|
|
|
|
52
|
$fields{$k} = $v; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 $t->read |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Reads the table into memory as instance variables |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub read |
71
|
|
|
|
|
|
|
{ |
72
|
6
|
|
|
6
|
1
|
24
|
my ($self) = @_; |
73
|
6
|
|
|
|
|
7
|
my ($dat); |
74
|
|
|
|
|
|
|
|
75
|
6
|
100
|
|
|
|
51
|
$self->SUPER::read or return $self; |
76
|
2
|
100
|
|
|
|
14
|
init unless defined $fields{'Ascender'}; |
77
|
2
|
|
|
|
|
11
|
$self->{' INFILE'}->read($dat, 36); |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
48
|
TTF_Read_Fields($self, $dat, \%fields); |
80
|
2
|
|
|
|
|
7
|
$self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 $t->out($fh) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Writes the table to a file either from memory or by copying. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub out |
91
|
|
|
|
|
|
|
{ |
92
|
2
|
|
|
2
|
1
|
5
|
my ($self, $fh) = @_; |
93
|
|
|
|
|
|
|
|
94
|
2
|
50
|
|
|
|
12
|
return $self->SUPER::out($fh) unless $self->{' read'}; |
95
|
|
|
|
|
|
|
|
96
|
2
|
|
33
|
|
|
16
|
$self->{'numberOfHMetrics'} = $self->{' PARENT'}{'hmtx'}->numMetrics || $self->{'numberOfHMetrics'}; |
97
|
2
|
|
|
|
|
10
|
$fh->print(TTF_Out_Fields($self, \%fields, 36)); |
98
|
2
|
|
|
|
|
16
|
$self; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 $t->minsize() |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns the minimum size this table can be. If it is smaller than this, then the table |
105
|
|
|
|
|
|
|
must be bad and should be deleted or whatever. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub minsize |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
0
|
1
|
|
return 36; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 $t->update |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Updates various parameters in the hhea table from the hmtx table. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub update |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
124
|
0
|
|
|
|
|
|
my ($hmtx) = $self->{' PARENT'}{'hmtx'}; |
125
|
0
|
|
|
|
|
|
my ($glyphs); |
126
|
0
|
|
|
|
|
|
my ($num, $res); |
127
|
0
|
|
|
|
|
|
my ($i, $maw, $mlsb, $mrsb, $mext, $aw, $lsb, $ext); |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
return undef unless ($self->SUPER::update); |
130
|
0
|
0
|
0
|
|
|
|
return undef unless (defined $hmtx && defined $self->{' PARENT'}{'loca'}); |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$hmtx->read->update; |
133
|
0
|
|
|
|
|
|
$self->{' PARENT'}{'loca'}->read->update; |
134
|
0
|
|
|
|
|
|
$glyphs = $self->{' PARENT'}{'loca'}{'glyphs'}; |
135
|
0
|
|
|
|
|
|
$num = $self->{' PARENT'}{'maxp'}{'numGlyphs'}; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
for ($i = 0; $i < $num; $i++) |
138
|
|
|
|
|
|
|
{ |
139
|
0
|
|
|
|
|
|
$aw = $hmtx->{'advance'}[$i]; |
140
|
0
|
|
|
|
|
|
$lsb = $hmtx->{'lsb'}[$i]; |
141
|
0
|
0
|
|
|
|
|
if (defined $glyphs->[$i]) |
142
|
0
|
|
|
|
|
|
{ $ext = $lsb + $glyphs->[$i]->read->{'xMax'} - $glyphs->[$i]{'xMin'}; } |
143
|
|
|
|
|
|
|
else |
144
|
0
|
|
|
|
|
|
{ $ext = $aw; } |
145
|
0
|
0
|
|
|
|
|
$maw = $aw if ($aw > $maw); |
146
|
0
|
0
|
0
|
|
|
|
$mlsb = $lsb if ($lsb < $mlsb or $i == 0); |
147
|
0
|
0
|
0
|
|
|
|
$mrsb = $aw - $ext if ($aw - $ext < $mrsb or $i == 0); |
148
|
0
|
0
|
|
|
|
|
$mext = $ext if ($ext > $mext); |
149
|
|
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
$self->{'advanceWidthMax'} = $maw; |
151
|
0
|
|
|
|
|
|
$self->{'minLeftSideBearing'} = $mlsb; |
152
|
0
|
|
|
|
|
|
$self->{'minRightSideBearing'} = $mrsb; |
153
|
0
|
|
|
|
|
|
$self->{'xMaxExtent'} = $mext; |
154
|
0
|
|
|
|
|
|
$self->{'numberOfHMetrics'} = $hmtx->numMetrics; |
155
|
0
|
|
|
|
|
|
$self; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 BUGS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
None known |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Martin Hosken L. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 LICENSING |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright (c) 1998-2014, SIL International (http://www.sil.org) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This module is released under the terms of the Artistic License 2.0. |
176
|
|
|
|
|
|
|
For details, see the full text of the license in the file LICENSE. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|