| 1 | #======================================================================= | ||
| 2 | # ____ ____ _____ _ ____ ___ ____ | ||
| 3 | # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \ | ||
| 4 | # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) | | ||
| 5 | # | __/| |_| | _| _ _ / ___ \| __/| | / __/ | ||
| 6 | # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____| | ||
| 7 | # | ||
| 8 | # A Perl Module Chain to faciliate the Creation and Modification | ||
| 9 | # of High-Quality "Portable Document Format (PDF)" Files. | ||
| 10 | # | ||
| 11 | #======================================================================= | ||
| 12 | # | ||
| 13 | # THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW: | ||
| 14 | # | ||
| 15 | # | ||
| 16 | # Copyright Jonathan Kew L<Jonathan_Kew@sil.org> | ||
| 17 | # | ||
| 18 | # No warranty or expression of effectiveness, least of all regarding | ||
| 19 | # anyone's safety, is implied in this software or documentation. | ||
| 20 | # | ||
| 21 | # This specific module is licensed under the Perl Artistic License. | ||
| 22 | # | ||
| 23 | # | ||
| 24 | # $Id: AATKern.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $ | ||
| 25 | # | ||
| 26 | #======================================================================= | ||
| 27 | package PDF::API3::Compat::API2::Basic::TTF::AATKern; | ||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | PDF::API3::Compat::API2::Basic::TTF::AATKern | ||
| 32 | |||
| 33 | =head1 METHODS | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | use strict; | ||
| 38 | use vars qw(@ISA); | ||
| 39 | use PDF::API3::Compat::API2::Basic::TTF::Utils; | ||
| 40 | use PDF::API3::Compat::API2::Basic::TTF::AATutils; | ||
| 41 | use PDF::API3::Compat::API2::Basic::TTF::Kern::Subtable; | ||
| 42 | |||
| 43 | @ISA = qw(PDF::API3::Compat::API2::Basic::TTF::Table); | ||
| 44 | |||
| 45 | =head2 $t->read | ||
| 46 | |||
| 47 | Reads the table into memory | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | sub read | ||
| 52 | { | ||
| 53 | my ($self) = @_; | ||
| 54 | |||
| 55 | $self->SUPER::read or return $self; | ||
| 56 | |||
| 57 | my ($dat, $fh, $numSubtables); | ||
| 58 | $fh = $self->{' INFILE'}; | ||
| 59 | |||
| 60 | $fh->read($dat, 8); | ||
| 61 | ($self->{'version'}, $numSubtables) = TTF_Unpack("fL", $dat); | ||
| 62 | |||
| 63 | my $subtables = []; | ||
| 64 | foreach (1 .. $numSubtables) { | ||
| 65 | my $subtableStart = $fh->tell(); | ||
| 66 | |||
| 67 | $fh->read($dat, 8); | ||
| 68 | my ($length, $coverage, $tupleIndex) = TTF_Unpack("LSS", $dat); | ||
| 69 | my $type = $coverage & 0x00ff; | ||
| 70 | |||
| 71 | my $subtable = PDF::API3::Compat::API2::Basic::TTF::Kern::Subtable->create($type, $coverage, $length); | ||
| 72 | $subtable->read($fh); | ||
| 73 | |||
| 74 | $subtable->{'tupleIndex'} = $tupleIndex if $subtable->{'variation'}; | ||
| 75 | $subtable->{' PARENT'} = $self; | ||
| 76 | push @$subtables, $subtable; | ||
| 77 | } | ||
| 78 | |||
| 79 | $self->{'subtables'} = $subtables; | ||
| 80 | |||
| 81 | $self; | ||
| 82 | } | ||
| 83 | |||
| 84 | =head2 $t->out($fh) | ||
| 85 | |||
| 86 | Writes the table to a file either from memory or by copying | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | sub out | ||
| 91 | { | ||
| 92 | my ($self, $fh) = @_; | ||
| 93 | |||
| 94 | return $self->SUPER::out($fh) unless $self->{' read'}; | ||
| 95 | |||
| 96 | my $subtables = $self->{'subtables'}; | ||
| 97 | $fh->print(TTF_Pack("fL", $self->{'version'}, scalar @$subtables)); | ||
| 98 | |||
| 99 | foreach (@$subtables) { | ||
| 100 | $_->out($fh); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | =head2 $t->print($fh) | ||
| 105 | |||
| 106 | Prints a human-readable representation of the table | ||
| 107 | |||
| 108 | =cut | ||
| 109 | |||
| 110 | sub print | ||
| 111 | { | ||
| 112 | my ($self, $fh) = @_; | ||
| 113 | |||
| 114 | $self->read unless $self->{' read'}; | ||
| 115 | |||
| 116 | $fh = 'STDOUT' unless defined $fh; | ||
| 117 | |||
| 118 | $fh->printf("version %f\n", $self->{'version'}); | ||
| 119 | |||
| 120 | my $subtables = $self->{'subtables'}; | ||
| 121 | foreach (@$subtables) { | ||
| 122 | $_->print($fh); | ||
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 | sub dumpXML | ||
| 127 | { | ||
| 128 | my ($self, $fh) = @_; | ||
| 129 | $self->read unless $self->{' read'}; | ||
| 130 | |||
| 131 | my $post = $self->{' PARENT'}->{'post'}; | ||
| 132 | $post->read; | ||
| 133 | |||
| 134 | $fh = 'STDOUT' unless defined $fh; | ||
| 135 | $fh->printf("<kern version=\"%f\">\n", $self->{'version'}); | ||
| 136 | |||
| 137 | my $subtables = $self->{'subtables'}; | ||
| 138 | foreach (@$subtables) { | ||
| 139 | $fh->printf("<%s", $_->type); | ||
| 140 | $fh->printf(" vertical=\"1\"") if $_->{'vertical'}; | ||
| 141 | $fh->printf(" crossStream=\"1\"") if $_->{'crossStream'}; | ||
| 142 | $fh->printf(" variation=\"1\"") if $_->{'variation'}; | ||
| 143 | $fh->printf(" tupleIndex=\"%s\"", $_->{'tupleIndex'}) if exists $_->{'tupleIndex'}; | ||
| 144 | $fh->printf(">\n"); | ||
| 145 | |||
| 146 | $_->dumpXML($fh); | ||
| 147 | |||
| 148 | $fh->printf("</%s>\n", $_->type); | ||
| 149 | } | ||
| 150 | |||
| 151 | $fh->printf("</kern>\n"); | ||
| 152 | } | ||
| 153 | |||
| 154 | 1; | ||
| 155 | |||
| 156 | =head1 BUGS | ||
| 157 | |||
| 158 | None known | ||
| 159 | |||
| 160 | =head1 AUTHOR | ||
| 161 | |||
| 162 | Jonathan Kew L<Jonathan_Kew@sil.org>. See L<PDF::API3::Compat::API2::Basic::TTF::Font> for copyright and | ||
| 163 | licensing. | ||
| 164 | |||
| 165 | =cut | ||
| 166 |