1 package Font::TTF::Mort::Chain;
 
   5 Font::TTF::Mort::Chain - Chain Mort subtable for AAT
 
  11 use Font::TTF::AATutils;
 
  12 use Font::TTF::Mort::Subtable;
 
  21     my ($class, %parms) = @_;
 
  25     $class = ref($class) || $class;
 
  26     foreach $p (keys %parms)
 
  27     { $self->{" $p"} = $parms{$p}; }
 
  33 Reads the chain into memory
 
  42     my $chainStart = $fh->tell();
 
  44     my ($defaultFlags, $chainLength, $nFeatureEntries, $nSubtables) = TTF_Unpack("LLSS", $dat);
 
  46     my $featureEntries = [];
 
  47     foreach (1 .. $nFeatureEntries) {
 
  49         my ($featureType, $featureSetting, $enableFlags, $disableFlags) = TTF_Unpack("SSLL", $dat);
 
  50         push @$featureEntries,    {
 
  51                                     'type'        => $featureType,
 
  52                                     'setting'    => $featureSetting,
 
  53                                     'enable'    => $enableFlags,
 
  54                                     'disable'    => $disableFlags
 
  59     foreach (1 .. $nSubtables) {
 
  60         my $subtableStart = $fh->tell();
 
  63         my ($length, $coverage, $subFeatureFlags) = TTF_Unpack("SSL", $dat);
 
  64         my $type = $coverage & 0x0007;
 
  66         my $subtable = Font::TTF::Mort::Subtable->create($type, $coverage, $subFeatureFlags, $length);
 
  68         $subtable->{' PARENT'} = $self;
 
  70         push @$subtables, $subtable;
 
  71         $fh->seek($subtableStart + $length, IO::File::SEEK_SET);
 
  74     $self->{'defaultFlags'} = $defaultFlags;
 
  75     $self->{'featureEntries'} = $featureEntries;
 
  76     $self->{'subtables'} = $subtables;
 
  78     $fh->seek($chainStart + $chainLength, IO::File::SEEK_SET);
 
  85 Writes the table to a file either from memory or by copying
 
  93     my $chainStart = $fh->tell();
 
  94     my ($featureEntries, $subtables) = ($_->{'featureEntries'}, $_->{'subtables'});
 
  95     $fh->print(TTF_Pack("LLSS", $_->{'defaultFlags'}, 0, scalar @$featureEntries, scalar @$subtables)); # placeholder for length
 
  97     foreach (@$featureEntries) {
 
  98         $fh->print(TTF_Pack("SSLL", $_->{'type'}, $_->{'setting'}, $_->{'enable'}, $_->{'disable'}));
 
 101     foreach (@$subtables) {
 
 105     my $chainLength = $fh->tell() - $chainStart;
 
 106     $fh->seek($chainStart + 4, IO::File::SEEK_SET);
 
 107     $fh->print(pack("N", $chainLength));
 
 108     $fh->seek($chainStart + $chainLength, IO::File::SEEK_SET);
 
 111 =head2 $t->print($fh)
 
 113 Prints a human-readable representation of the chain
 
 121     my $feat = $self->{' PARENT'}{' PARENT'}{'feat'};
 
 134     my ($self, $fh) = @_;
 
 136     $fh->printf("version %f\n", $self->{'version'});
 
 138     my $defaultFlags = $self->{'defaultFlags'};
 
 139     $fh->printf("chain: defaultFlags = %08x\n", $defaultFlags);
 
 141     my $feat = $self->feat();
 
 142     my $featureEntries = $self->{'featureEntries'};
 
 143     foreach (@$featureEntries) {
 
 144         $fh->printf("\tfeature %d, setting %d : enableFlags = %08x, disableFlags = %08x # '%s: %s'\n",
 
 145                     $_->{'type'}, $_->{'setting'}, $_->{'enable'}, $_->{'disable'},
 
 146                     $feat->settingName($_->{'type'}, $_->{'setting'}));
 
 149     my $subtables = $self->{'subtables'};
 
 150     foreach (@$subtables) {
 
 151         my $type = $_->{'type'};
 
 152         my $subFeatureFlags = $_->{'subFeatureFlags'};
 
 153         $fh->printf("\n\t%s table, %s, %s, subFeatureFlags = %08x # %s (%s)\n",
 
 154                     subtable_type_($type), $_->{'direction'}, $_->{'orientation'}, $subFeatureFlags,
 
 155                     "Default " . ((($subFeatureFlags & $defaultFlags) != 0) ? "On" : "Off"),
 
 158                             join(": ", $feat->settingName($_->{'type'}, $_->{'setting'}) )
 
 159                         } grep { ($_->{'enable'} & $subFeatureFlags) != 0 } @$featureEntries
 
 179     $res = $types[$val] or ('Undefined (' . $val . ')');
 
 192 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<Font::TTF::Font> for copyright and