X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/ef7911fba9c330552599bc6eb9dc22606246dd7e..68b03397a0872d10d3627cea2b92ae36bd59183c:/font-optimizer/ext/Font-TTF/lib/Font/TTF/Kern/StateTable.pm
diff --git a/font-optimizer/ext/Font-TTF/lib/Font/TTF/Kern/StateTable.pm b/font-optimizer/ext/Font-TTF/lib/Font/TTF/Kern/StateTable.pm
new file mode 100644
index 0000000..51d650a
--- /dev/null
+++ b/font-optimizer/ext/Font-TTF/lib/Font/TTF/Kern/StateTable.pm
@@ -0,0 +1,143 @@
+package Font::TTF::Kern::StateTable;
+
+=head1 NAME
+
+Font::TTF::Kern::StateTable - State Table Kern subtable for AAT
+
+=head1 METHODS
+
+=cut
+
+use strict;
+use vars qw(@ISA);
+use Font::TTF::Utils;
+use Font::TTF::AATutils;
+use Font::TTF::Kern::Subtable;
+use IO::File;
+
+@ISA = qw(Font::TTF::Kern::Subtable);
+
+sub new
+{
+ my ($class) = @_;
+ my ($self) = {};
+
+ $class = ref($class) || $class;
+ bless $self, $class;
+}
+
+=head2 $t->read
+
+Reads the table into memory
+
+=cut
+
+sub read
+{
+ my ($self, $fh) = @_;
+ my ($dat);
+
+ my $stTableStart = $fh->tell();
+
+ my ($classes, $states, $entries) = AAT_read_state_table($fh, 0);
+
+ foreach (@$entries) {
+ my $flags = $_->{'flags'};
+ delete $_->{'flags'};
+ $_->{'push'} = 1 if $flags & 0x8000;
+ $_->{'noAdvance'} = 1 if $flags & 0x4000;
+ $flags &= ~0xC000;
+ if ($flags != 0) {
+ my $kernList = [];
+ $fh->seek($stTableStart + $flags, IO::File::SEEK_SET);
+ while (1) {
+ $fh->read($dat, 2);
+ my $k = TTF_Unpack("s", $dat);
+ push @$kernList, ($k & ~1);
+ last if ($k & 1) != 0;
+ }
+ $_->{'kernList'} = $kernList;
+ }
+ }
+
+ $self->{'classes'} = $classes;
+ $self->{'states'} = $states;
+ $self->{'entries'} = $entries;
+
+ $fh->seek($stTableStart - 8 + $self->{'length'}, IO::File::SEEK_SET);
+
+ $self;
+}
+
+=head2 $t->out_sub($fh)
+
+Writes the table to a file
+
+=cut
+
+sub out_sub
+{
+}
+
+=head2 $t->print($fh)
+
+Prints a human-readable representation of the table
+
+=cut
+
+sub print
+{
+}
+
+sub dumpXML
+{
+ my ($self, $fh) = @_;
+
+ $fh->printf("\n");
+ $self->dumpClasses($self->{'classes'}, $fh);
+ $fh->printf("\n");
+
+ $fh->printf("\n");
+ my $states = $self->{'states'};
+ foreach (0 .. $#$states) {
+ $fh->printf("\n", $_);
+ my $members = $states->[$_];
+ foreach (0 .. $#$members) {
+ my $m = $members->[$_];
+ $fh->printf("{'nextState'});
+ $fh->printf(" push=\"1\"") if $m->{'push'};
+ $fh->printf(" noAdvance=\"1\"") if $m->{'noAdvance'};
+ if (exists $m->{'kernList'}) {
+ $fh->printf(">");
+ foreach (@{$m->{'kernList'}}) {
+ $fh->printf("", $_);
+ }
+ $fh->printf("\n");
+ }
+ else {
+ $fh->printf("/>\n");
+ }
+ }
+ $fh->printf("\n");
+ }
+ $fh->printf("\n");
+}
+
+sub type
+{
+ return 'kernStateTable';
+}
+
+1;
+
+=head1 BUGS
+
+None known
+
+=head1 AUTHOR
+
+Jonathan Kew L. See L for copyright and
+licensing.
+
+=cut
+