1 package Font::TTF::Kern::Subtable;
5 Font::TTF::Kern::Subtable - Kern Subtable superclass for AAT
13 use Font::TTF::AATutils;
16 require Font::TTF::Kern::OrderedList;
17 require Font::TTF::Kern::StateTable;
18 require Font::TTF::Kern::ClassArray;
19 require Font::TTF::Kern::CompactClassArray;
26 $class = ref($class) || $class;
33 my ($class, $type, $coverage, $length) = @_;
35 $class = ref($class) || $class;
39 $subclass = 'Font::TTF::Kern::OrderedList';
42 $subclass = 'Font::TTF::Kern::StateTable';
45 $subclass = 'Font::TTF::Kern::ClassArray';
48 $subclass = 'Font::TTF::Kern::CompactClassArray';
52 push @options,'vertical' if ($coverage & 0x8000) != 0;
53 push @options,'crossStream' if ($coverage & 0x4000) != 0;
54 push @options,'variation' if ($coverage & 0x2000) != 0;
56 my ($subTable) = $subclass->new(@options);
58 map { $subTable->{$_} = 1 } @options;
60 $subTable->{'type'} = $type;
61 $subTable->{'length'} = $length;
68 Writes the table to a file
76 my $subtableStart = $fh->tell();
77 my $type = $self->{'type'};
79 $coverage += 0x8000 if $self->{'vertical'};
80 $coverage += 0x4000 if $self->{'crossStream'};
81 $coverage += 0x2000 if $self->{'variation'};
83 $fh->print(TTF_Pack("LSS", 0, $coverage, $self->{'tupleIndex'})); # placeholder for length
87 my $length = $fh->tell() - $subtableStart;
88 my $padBytes = (4 - ($length & 3)) & 3;
89 $fh->print(pack("C*", (0) x $padBytes));
91 $fh->seek($subtableStart, IO::File::SEEK_SET);
92 $fh->print(pack("N", $length));
93 $fh->seek($subtableStart + $length, IO::File::SEEK_SET);
98 Prints a human-readable representation of the table
106 my $post = $self->{' PARENT'}{' PARENT'}{'post'};
119 my ($self, $fh) = @_;
121 my $post = $self->post();
122 $fh = 'STDOUT' unless defined $fh;
125 =head2 $t->print_classes($fh)
127 Prints a human-readable representation of the table
133 my ($self, $fh) = @_;
135 my $post = $self->post();
137 my $classes = $self->{'classes'};
138 foreach (0 .. $#$classes) {
139 my $class = $classes->[$_];
140 if (defined $class) {
141 $fh->printf("\t\tClass %d:\t%s\n", $_, join(", ", map { $_ . " [" . $post->{'VAL'}[$_] . "]" } @$class));
148 my ($self, $classes, $fh) = @_;
149 my $post = $self->post();
151 foreach (0 .. $#$classes) {
152 my $c = $classes->[$_];
154 $fh->printf("<class n=\"%s\">\n", $_);
156 $fh->printf("<g index=\"%s\" name=\"%s\"/>\n", $_, $post->{'VAL'}[$_]);
158 $fh->printf("</class>\n");
171 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<Font::TTF::Font> for copyright and