/usr/share/perl5/Font/TTF/Ttc.pm is in libfont-ttf-perl 1.04-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | package Font::TTF::Ttc;
=head1 NAME
Font::TTF::Ttc - Truetype Collection class
=head1 DESCRIPTION
A TrueType collection is a collection of TrueType fonts in one file in which
tables may be shared between different directories. In order to support this,
the TTC introduces the concept of a table being shared by different TrueType
fonts. This begs the question of what should happen to the ' PARENT' property
of a particular table. It is made to point to the first directory object which
refers to it. It is therefore up to the application to sort out any confusion.
Confusion only occurs if shared tables require access to non-shared tables.
This should not happen since the shared tables are dealing with glyph
information only and the private tables are dealing with encoding and glyph
identification. Thus the general direction is from identification to glyph and
not the other way around (at least not without knowledge of the particular
context).
=head1 INSTANCE VARIABLES
The following instance variables are preceded by a space
=over 4
=item fname (P)
Filename for this TrueType Collection
=item INFILE (P)
The filehandle of this collection
=back
The following instance variable does not start with a space
=over 4
=item directs
An array of directories (Font::TTF::Font objects) for each sub-font in the directory
=back
=head1 METHODS
=cut
use strict;
use vars qw($VERSION);
use IO::File;
$VERSION = 0.0001;
=head2 Font::TTF::Ttc->open($fname)
Opens and reads the given filename as a TrueType Collection. Reading a collection
involves reading each of the directories which go to make up the collection.
=cut
sub open
{
my ($class, $fname) = @_;
my ($self) = {};
my ($fh);
unless (ref($fname))
{
$fh = IO::File->new($fname) or return undef;
binmode $fh;
} else
{ $fh = $fname; }
bless $self, $class;
$self->{' INFILE'} = $fh;
$self->{' fname'} = $fname;
$fh->seek(0, 0);
$self->read;
}
=head2 $c->read
Reads a Collection by reading all the directories in the collection
=cut
sub read
{
my ($self) = @_;
my ($fh) = $self->{' INFILE'};
my ($dat, $ttc, $ver, $num, $i, $loc);
$fh->read($dat, 12);
($ttc, $ver, $num) = unpack("A4N2", $dat);
return undef unless $ttc eq "ttcf";
$fh->read($dat, $num << 2);
for ($i = 0; $i < $num; $i++)
{
$loc = unpack("N", substr($dat, $i << 2, 4));
$self->{'directs'}[$i] = Font::TTF::Font->new('INFILE' => $fh,
'PARENT' => $self,
'OFFSET' => $loc) || return undef;
}
for ($i = 0; $i < $num; $i++)
{ $self->{'directs'}[$i]->read; }
$self;
}
=head2 $c->find($direct, $name, $check, $off, $len)
Hunts around to see if a table with the given characteristics of name, checksum,
offset and length has been associated with a directory earlier in the list.
Actually on checks the offset since no two tables can share the same offset in
a TrueType font, collection or otherwise.
=cut
sub find
{
my ($self, $direct, $name, $check, $off, $len) = @_;
my ($d);
foreach $d (@{$self->{'directs'}})
{
return undef if $d eq $direct;
next unless defined $d->{$name};
return $d->{$name} if ($d->{$name}{' OFFSET'} == $off);
}
undef; # wierd that the font passed is not in the list!
}
=head2 $c->DESTROY
Closees any opened files by us
=cut
sub DESTROY
{
my ($self) = @_;
close ($self->{' INFILE'}) if $self->{' INFILE'};
undef;
}
1;
=head1 BUGS
No known bugs, but then not ever executed!
=head1 AUTHOR
Martin Hosken L<Martin_Hosken@sil.org>.
=head1 LICENSING
Copyright (c) 1998-2013, SIL International (http://www.sil.org)
This module is released under the terms of the Artistic License 2.0.
For details, see the full text of the license in the file LICENSE.
=cut
|