Introduce src dir.
[librarian.git] / src / librarian / font-optimizer / ext / Font-TTF / lib / Font / TTF / Fmtx.pm
1 package Font::TTF::Fmtx;
2
3 =head1 NAME
4
5 Font::TTF::Fmtx - Font Metrics table
6
7 =head1 DESCRIPTION
8
9 This is a simple table with just standards specified instance variables
10
11 =head1 INSTANCE VARIABLES
12
13     version
14     glyphIndex
15     horizontalBefore
16     horizontalAfter
17     horizontalCaretHead
18     horizontalCaretBase
19     verticalBefore
20     verticalAfter
21     verticalCaretHead
22     verticalCaretBase
23
24 =head1 METHODS
25
26 =cut
27
28 use strict;
29 use vars qw(@ISA %fields @field_info);
30
31 require Font::TTF::Table;
32 use Font::TTF::Utils;
33
34 @ISA = qw(Font::TTF::Table);
35 @field_info = (
36     'version' => 'v',
37     'glyphIndex' => 'L',
38     'horizontalBefore' => 'c',
39     'horizontalAfter' => 'c',
40     'horizontalCaretHead' => 'c',
41     'horizontalCaretBase' => 'c',
42     'verticalBefore' => 'c',
43     'verticalAfter' => 'c',
44     'verticalCaretHead' => 'c',
45     'verticalCaretBase' => 'c');
46
47 sub init
48 {
49     my ($k, $v, $c, $i);
50     for ($i = 0; $i < $#field_info; $i += 2)
51     {
52         ($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]);
53         next unless defined $k && $k ne "";
54         $fields{$k} = $v;
55     }
56 }
57
58
59 =head2 $t->read
60
61 Reads the table into memory as instance variables
62
63 =cut
64
65 sub read
66 {
67     my ($self) = @_;
68     my ($dat);
69
70     $self->SUPER::read or return $self;
71     init unless defined $fields{'glyphIndex'};
72     $self->{' INFILE'}->read($dat, 16);
73
74     TTF_Read_Fields($self, $dat, \%fields);
75     $self;
76 }
77
78
79 =head2 $t->out($fh)
80
81 Writes the table to a file either from memory or by copying.
82
83 =cut
84
85 sub out
86 {
87     my ($self, $fh) = @_;
88
89     return $self->SUPER::out($fh) unless $self->{' read'};
90
91     $fh->print(TTF_Out_Fields($self, \%fields, 16));
92     $self;
93 }
94
95
96 1;
97
98
99 =head1 BUGS
100
101 None known
102
103 =head1 AUTHOR
104
105 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<Font::TTF::Font> for copyright and
106 licensing.
107
108 =cut