1 package Font::TTF::Mort::Insertion;
5 Font::TTF::Mort::Insertion - Insertion Mort subtable for AAT
14 use Font::TTF::AATutils;
17 @ISA = qw(Font::TTF::Mort::Subtable);
21 my ($class, $direction, $orientation, $subFeatureFlags) = @_;
23 'direction' => $direction,
24 'orientation' => $orientation,
25 'subFeatureFlags' => $subFeatureFlags
28 $class = ref($class) || $class;
34 Reads the table into memory
43 my $subtableStart = $fh->tell();
45 my $stateTableStart = $fh->tell();
46 my ($classes, $states, $entries) = AAT_read_state_table($fh, 2);
51 my $flags = $_->{'flags'};
52 my @insertCount = (($flags & 0x03e0) >> 5, ($flags & 0x001f));
53 my $actions = $_->{'actions'};
55 if ($insertCount[$_] > 0) {
56 $fh->seek($stateTableStart + $actions->[$_], IO::File::SEEK_SET);
57 $fh->read($dat, $insertCount[$_] * 2);
58 if (not defined $insertListHash{$dat}) {
59 push @$insertLists, [unpack("n*", $dat)];
60 $insertListHash{$dat} = $#$insertLists;
62 $actions->[$_] = $insertListHash{$dat};
65 $actions->[$_] = undef;
70 $self->{'classes'} = $classes;
71 $self->{'states'} = $states;
72 $self->{'insertLists'} = $insertLists;
85 my ($dat) = pack("nnnn", (0) x 4);
87 my $classTable = length($dat);
88 my $classes = $self->{'classes'};
89 $dat .= AAT_pack_classes($classes);
91 my $stateArray = length($dat);
92 my $states = $self->{'states'};
93 my ($dat1, $stateSize, $entries) = AAT_pack_states($classes, $stateArray, $states,
95 my $actions = $_->{'actions'};
96 ( $_->{'flags'}, @$actions )
101 my $entryTable = length($dat);
102 my $offset = ($entryTable + 8 * @$entries);
104 my $insertLists = $self->{'insertLists'};
105 foreach (@$insertLists) {
106 push @insListOffsets, $offset;
107 $offset += 2 * scalar @$_;
109 foreach (@$entries) {
110 my ($nextState, $flags, @lists) = split /,/;
112 $flags |= (scalar @{$insertLists->[$lists[0]]}) << 5 if $lists[0] ne '';
113 $flags |= (scalar @{$insertLists->[$lists[1]]}) if $lists[1] ne '';
114 $dat .= pack("nnnn", $nextState, $flags,
115 map { $_ eq '' ? 0 : $insListOffsets[$_] } @lists);
118 foreach (@$insertLists) {
119 $dat .= pack("n*", @$_);
122 $dat1 = pack("nnnn", $stateSize, $classTable, $stateArray, $entryTable);
123 substr($dat, 0, length($dat1)) = $dat1;
128 =head2 $t->print($fh)
130 Prints a human-readable representation of the table
136 my ($self, $fh) = @_;
138 my $post = $self->post();
140 $fh = 'STDOUT' unless defined $fh;
142 $self->print_classes($fh);
145 my $states = $self->{'states'};
146 foreach (0 .. $#$states) {
147 $fh->printf("\t\tState %d:", $_);
148 my $state = $states->[$_];
151 $flags .= "!" if ($_->{'flags'} & 0x4000);
152 $flags .= "*" if ($_->{'flags'} & 0x8000);
153 my $actions = $_->{'actions'};
154 $fh->printf("\t(%s%d,%s,%s)", $flags, $_->{'nextState'}, map { defined $_ ? $_ : "=" } @$actions);
160 my $insertLists = $self->{'insertLists'};
161 foreach (0 .. $#$insertLists) {
162 my $insertList = $insertLists->[$_];
163 $fh->printf("\t\tList %d: %s\n", $_, join(", ", map { $_ . " [" . $post->{'VAL'}[$_] . "]" } @$insertList));
175 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<Font::TTF::Font> for copyright and