Introduce src dir.
[librarian.git] / src / librarian / font-optimizer / ext / Font-TTF / lib / Font / TTF / LTSH.pm
1 package Font::TTF::LTSH;
2
3 =head1 NAME
4
5 Font::TTF::LTSH - Linear Threshold table
6
7 =head1 DESCRIPTION
8
9 Holds the linear threshold for each glyph. This is the ppem value at which a
10 glyph's metrics become linear. The value is set to 1 if a glyph's metrics are
11 always linear.
12
13 =head1 INSTANCE VARIABLES
14
15 =over 4
16
17 =item glyphs
18
19 An array of ppem values. One value per glyph
20
21 =back
22
23 =head1 METHODS
24
25 =cut
26
27 use strict;
28 use vars qw(@ISA);
29 use Font::TTF::Table;
30
31 @ISA = qw(Font::TTF::Table);
32
33 =head2 $t->read
34
35 Reads the table
36
37 =cut
38
39 sub read
40 {
41     my ($self) = @_;
42     my ($fh) = $self->{' INFILE'};
43     my ($numg, $dat);
44
45     $self->SUPER::read or return $self;
46
47     $fh->read($dat, 4);
48     ($self->{'Version'}, $numg) = unpack("nn", $dat);
49     $self->{'Num'} = $numg;
50
51     $fh->read($dat, $numg);
52     $self->{'glyphs'} = [unpack("C$numg", $dat)];
53     $self;
54 }
55
56
57 =head2 $t->out($fh)
58
59 Outputs the LTSH to the given fh.
60
61 =cut
62
63 sub out
64 {
65     my ($self, $fh) = @_;
66     my ($numg) = $self->{' PARENT'}{'maxp'}{'numGlyphs'};
67
68     return $self->SUPER::out($fh) unless ($self->{' read'});
69
70     $fh->print(pack("nn", 0, $numg));
71     $fh->print(pack("C$numg", @{$self->{'glyphs'}}));
72     $self;
73 }
74     
75
76 1;
77
78 =head1 BUGS
79
80 None known
81
82 =head1 AUTHOR
83
84 Martin Hosken Martin_Hosken@sil.org. See L<Font::TTF::Font> for copyright and
85 licensing.
86
87 =cut
88