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

=head1 NAME

Font::TTF::Mort::Rearrangement - Rearrangement Mort subtable for AAT

=head1 METHODS

=cut

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

@ISA = qw(Font::TTF::Mort::Subtable);

sub new
{
    my ($class, $direction, $orientation, $subFeatureFlags) = @_;
    my ($self) = {
                    'direction'            =&gt; $direction,
                    'orientation'        =&gt; $orientation,
                    'subFeatureFlags'    =&gt; $subFeatureFlags
                };

    $class = ref($class) || $class;
    bless $self, $class;
}

=head2 $t-&gt;read

Reads the table into memory

=cut

sub read
{
    my ($self, $fh) = @_;
    
    my ($classes, $states) = AAT_read_state_table($fh, 0);
    $self-&gt;{'classes'} = $classes;
    $self-&gt;{'states'} = $states;
            
    $self;
}

=head2 $t-&gt;pack_sub()

=cut

sub pack_sub
{
    my ($self) = @_;
    
    return AAT_pack_state_table($self-&gt;{'classes'}, $self-&gt;{'states'}, 0);
}

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

Prints a human-readable representation of the table

=cut

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

    $self-&gt;print_classes($fh);

    $fh-&gt;print("\n");
    my $states = $self-&gt;{'states'};
    my @verbs = (    "0", "Ax-&gt;xA", "xD-&gt;Dx", "AxD-&gt;DxA",
                    "ABx-&gt;xAB", "ABx-&gt;xBA", "xCD-&gt;CDx", "xCD-&gt;DCx",
                    "AxCD-&gt;CDxA", "AxCD-&gt;DCxA", "ABxD-&gt;DxAB", "ABxD-&gt;DxBA",
                    "ABxCD-&gt;CDxAB", "ABxCD-&gt;CDxBA", "ABxCD-&gt;DCxAB", "ABxCD-&gt;DCxBA");
    foreach (0 .. $#$states) {
        $fh-&gt;printf("\t\tState %d:", $_);
        my $state = $states-&gt;[$_];
        foreach (@$state) {
            my $flags;
            $flags .= "!" if ($_-&gt;{'flags'} &amp; 0x4000);
            $flags .= "&lt;" if ($_-&gt;{'flags'} &amp; 0x8000);
            $flags .= "&gt;" if ($_-&gt;{'flags'} &amp; 0x2000);
            $fh-&gt;printf("\t(%s%d,%s)", $flags, $_-&gt;{'nextState'}, $verbs[($_-&gt;{'flags'} &amp; 0x000f)]);
        }
        $fh-&gt;print("\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>