1 package Font::TTF::Ttc;
5 Font::TTF::Ttc - Truetype Collection class
9 A TrueType collection is a collection of TrueType fonts in one file in which
10 tables may be shared between different directories. In order to support this,
11 the TTC introduces the concept of a table being shared by different TrueType
12 fonts. This begs the question of what should happen to the ' PARENT' property
13 of a particular table. It is made to point to the first directory object which
14 refers to it. It is therefore up to the application to sort out any confusion.
15 Confusion only occurs if shared tables require access to non-shared tables.
16 This should not happen since the shared tables are dealing with glyph
17 information only and the private tables are dealing with encoding and glyph
18 identification. Thus the general direction is from identification to glyph and
19 not the other way around (at least not without knowledge of the particular
22 =head1 INSTANCE VARIABLES
24 The following instance variables are preceded by a space
30 Filename for this TrueType Collection
34 The filehandle of this collection
38 The following instance variable does not start with a space
44 An array of directories (Font::TTF::Font objects) for each sub-font in the directory
53 use vars qw($VERSION);
59 =head2 Font::TTF::Ttc->open($fname)
61 Opens and reads the given filename as a TrueType Collection. Reading a collection
62 involves reading each of the directories which go to make up the collection.
68 my ($class, $fname) = @_;
74 $fh = IO::File->new($fname) or return undef;
80 $self->{' INFILE'} = $fh;
81 $self->{' fname'} = $fname;
89 Reads a Collection by reading all the directories in the collection
96 my ($fh) = $self->{' INFILE'};
97 my ($dat, $ttc, $ver, $num, $i, $loc);
100 ($ttc, $ver, $num) = unpack("A4N2", $dat);
102 return undef unless $ttc eq "ttcf";
103 $fh->read($dat, $num << 2);
104 for ($i = 0; $i < $num; $i++)
106 $loc = unpack("N", substr($dat, $i << 2, 4));
107 $self->{'directs'}[$i] = Font::TTF::Font->new('INFILE' => $fh,
109 'OFFSET' => $loc) || return undef;
111 for ($i = 0; $i < $num; $i++)
112 { $self->{'directs'}[$i]->read; }
117 =head2 $c->find($direct, $name, $check, $off, $len)
119 Hunts around to see if a table with the given characteristics of name, checksum,
120 offset and length has been associated with a directory earlier in the list.
121 Actually on checks the offset since no two tables can share the same offset in
122 a TrueType font, collection or otherwise.
128 my ($self, $direct, $name, $check, $off, $len) = @_;
131 foreach $d (@{$self->{'directs'}})
133 return undef if $d eq $direct;
134 next unless defined $d->{$name};
135 return $d->{$name} if ($d->{$name}{' OFFSET'} == $off);
137 undef; # wierd that the font passed is not in the list!
143 Closees any opened files by us
150 close ($self->{' INFILE'});
156 No known bugs, but then not ever executed!
160 Martin Hosken Martin_Hosken@sil.org. See L<Font::TTF::Font> for copyright and