<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Font::TTF::AATKern;

=head1 NAME

Font::TTF::AATKern - AAT Kern table

=head1 METHODS

=cut

use strict;
use vars qw(@ISA);
use Font::TTF::Utils;
use Font::TTF::AATutils;
use Font::TTF::Kern::Subtable;

@ISA = qw(Font::TTF::Table);

=head2 $t-&gt;read

Reads the table into memory

=cut

sub read
{
    my ($self) = @_;
    
    $self-&gt;SUPER::read or return $self;

    my ($dat, $fh, $numSubtables);
    $fh = $self-&gt;{' INFILE'};

    $fh-&gt;read($dat, 8);
    ($self-&gt;{'version'}, $numSubtables) = TTF_Unpack("vL", $dat);
    
    my $subtables = [];
    foreach (1 .. $numSubtables) {
        my $subtableStart = $fh-&gt;tell();
        
        $fh-&gt;read($dat, 8);
        my ($length, $coverage, $tupleIndex) = TTF_Unpack("LSS", $dat);
        my $type = $coverage &amp; 0x00ff;

        my $subtable = Font::TTF::Kern::Subtable-&gt;create($type, $coverage, $length);
        $subtable-&gt;read($fh);

        $subtable-&gt;{'tupleIndex'} = $tupleIndex if $subtable-&gt;{'variation'};
        $subtable-&gt;{' PARENT'} = $self;
        push @$subtables, $subtable;
    }

    $self-&gt;{'subtables'} = $subtables;

    $self;
}

=head2 $t-&gt;out($fh)

Writes the table to a file either from memory or by copying

=cut

sub out
{
    my ($self, $fh) = @_;
    
    return $self-&gt;SUPER::out($fh) unless $self-&gt;{' read'};

    my $subtables = $self-&gt;{'subtables'};
    $fh-&gt;print(TTF_Pack("vL", $self-&gt;{'version'}, scalar @$subtables));

    foreach (@$subtables) {
        $_-&gt;out($fh);
    }
}

=head2 $t-&gt;print($fh)

Prints a human-readable representation of the table

=cut

sub print
{
    my ($self, $fh) = @_;
    
    $self-&gt;read unless $self-&gt;{' read'};
    
    $fh = 'STDOUT' unless defined $fh;

    $fh-&gt;printf("version %f\n", $self-&gt;{'version'});
    
    my $subtables = $self-&gt;{'subtables'};
    foreach (@$subtables) {
        $_-&gt;print($fh);
    }
}

sub dumpXML
{
    my ($self, $fh) = @_;
    $self-&gt;read unless $self-&gt;{' read'};

    my $post = $self-&gt;{' PARENT'}-&gt;{'post'};
    $post-&gt;read;
    
    $fh = 'STDOUT' unless defined $fh;
    $fh-&gt;printf("&lt;kern version=\"%f\"&gt;\n", $self-&gt;{'version'});
    
    my $subtables = $self-&gt;{'subtables'};
    foreach (@$subtables) {
        $fh-&gt;printf("&lt;%s", $_-&gt;type);
        $fh-&gt;printf(" vertical=\"1\"") if $_-&gt;{'vertical'};
        $fh-&gt;printf(" crossStream=\"1\"") if $_-&gt;{'crossStream'};
        $fh-&gt;printf(" variation=\"1\"") if $_-&gt;{'variation'};
        $fh-&gt;printf(" tupleIndex=\"%s\"", $_-&gt;{'tupleIndex'}) if exists $_-&gt;{'tupleIndex'};
        $fh-&gt;printf("&gt;\n");

        $_-&gt;dumpXML($fh);

        $fh-&gt;printf("&lt;/%s&gt;\n", $_-&gt;type);
    }

    $fh-&gt;printf("&lt;/kern&gt;\n");
}

1;

=head1 BUGS

None known

=head1 AUTHOR

Jonathan Kew L&lt;Jonathan_Kew@sil.org&gt;. See L&lt;Font::TTF::Font&gt; for copyright and
licensing.

=cut

</pre></body></html>