Version bump.
[librarian.git] / librarian / font-optimizer / ext / Font-TTF / lib / Font / TTF / PCLT.pm
1 package Font::TTF::PCLT;
2
3 =head1 NAME
4
5 Font::TTF::PCLT - PCLT TrueType font table
6
7 =head1 DESCRIPTION
8
9 The PCLT table holds various pieces HP-PCL specific information. Information
10 here is generally not used by other software, except for the xHeight and
11 CapHeight which are stored here (if the table exists in a font).
12
13 =head1 INSTANCE VARIABLES
14
15 Only from table and the standard:
16
17     version
18     FontNumber
19     Pitch
20     xHeight
21     Style
22     TypeFamily
23     CapHeight
24     SymbolSet
25     Typeface
26     CharacterComplement
27     FileName
28     StrokeWeight
29     WidthType
30     SerifStyle
31
32 Notice that C<Typeface>, C<CharacterComplement> and C<FileName> return arrays
33 of unsigned characters of the appropriate length
34
35 =head1 METHODS
36
37 =cut
38
39 use strict;
40 use vars qw(@ISA %fields @field_info);
41
42 require Font::TTF::Table;
43 use Font::TTF::Utils;
44
45 @ISA = qw(Font::TTF::Table);
46 @field_info = (
47     'version' => 'v',
48     'FontNumber' => 'L',
49     'Pitch' => 'S',
50     'xHeight' => 'S',
51     'Style' => 'S',
52     'TypeFamily' => 'S',
53     'CapHeight' => 'S',
54     'SymbolSet' => 'S',
55     'Typeface' => 'C16',
56     'CharacterComplement' => 'C8',
57     'FileName' => 'C6',
58     'StrokeWeight' => 'C',
59     'WidthType' => 'C',
60     'SerifStyle' => 'c');
61
62 sub init
63 {
64     my ($k, $v, $c, $i);
65     for ($i = 0; $i < $#field_info; $i += 2)
66     {
67         ($k, $v, $c) = TTF_Init_Fields($field_info[$i], $c, $field_info[$i + 1]);
68         next unless defined $k && $k ne "";
69         $fields{$k} = $v;
70     }
71 }
72
73
74 =head2 $t->read
75
76 Reads the table into memory thanks to some utility functions
77
78 =cut
79
80 sub read
81 {
82     my ($self) = @_;
83     my ($dat);
84
85     $self->SUPER::read || return $self;
86
87     init unless defined $fields{'xHeight'};
88     $self->{' INFILE'}->read($dat, 54);
89
90     TTF_Read_Fields($self, $dat, \%fields);
91     $self;
92 }
93
94
95 =head2 $t->out($fh)
96
97 Writes the table to a file either from memory or by copying.
98
99 =cut
100
101 sub out
102 {
103     my ($self, $fh) = @_;
104
105     return $self->SUPER::out($fh) unless $self->{' read'};
106     $fh->print(TTF_Out_Fields($self, \%fields, 54));
107 }
108
109 1;
110
111 =head1 BUGS
112
113 None known
114
115 =head1 AUTHOR
116
117 Martin Hosken Martin_Hosken@sil.org. See L<Font::TTF::Font> for copyright and
118 licensing.
119
120 =cut
121