API3/Compat/API2/Basic/TTF/Kern/OrderedList.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 70 CC 3 SCAR 12.4
CC
3
Cov
0%
read
6.0
dumpXML
6.0
new
2.0
CRAP 3.5
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: OrderedList.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $
25 #
26 #=======================================================================
27 package PDF::API3::Compat::API2::Basic::TTF::Kern::OrderedList;
28
29 =head1 NAME
30
31 PDF::API3::Compat::API2::Basic::TTF::Kern::OrderedList
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
42 @ISA = qw(PDF::API3::Compat::API2::Basic::TTF::Kern::Subtable);
43
44 sub new
45 {
46 my ($class, @options) = @_;
47 my ($self) = {};
48
49 $class = ref($class) || $class;
50 bless $self, $class;
51 }
52
53 =head2 $t->read
54
55 Reads the table into memory
56
57 =cut
58
59 sub read
60 {
61 my ($self, $fh) = @_;
62
63 my $dat;
64 $fh->read($dat, 8);
65 my ($nPairs, $searchRange, $entrySelector, $rangeShift) = unpack("nnnn", $dat);
66
67 my $pairs = [];
68 foreach (1 .. $nPairs) {
69 $fh->read($dat, 6);
70 my ($left, $right, $kern) = TTF_Unpack("SSs", $dat);
71 push @$pairs, { 'left' => $left, 'right' => $right, 'kern' => $kern } if $kern != 0;
72 }
73
74 $self->{'kernPairs'} = $pairs;
75
76 $self;
77 }
78
79 =head2 $t->out_sub($fh)
80
81 Writes the table to a file
82
83 =cut
84
85 sub out_sub
86 {
87 my ($self, $fh) = @_;
88
89 my $pairs = $self->{'kernPairs'};
90 $fh->print(pack("nnnn", TTF_bininfo(scalar @$pairs, 6)));
91
92 foreach (sort { $a->{'left'} <=> $b->{'left'} or $a->{'right'} <=> $b->{'right'} } @$pairs) {
93 $fh->print(TTF_Pack("SSs", $_->{'left'}, $_->{'right'}, $_->{'kern'}));
94 }
95 }
96
97 =head2 $t->print($fh)
98
99 Prints a human-readable representation of the table
100
101 =cut
102
103 sub dumpXML
104 {
105 my ($self, $fh) = @_;
106
107 my $postVal = $self->post()->{'VAL'};
108
109 $fh = 'STDOUT' unless defined $fh;
110 foreach (@{$self->{'kernPairs'}}) {
111 $fh->printf("<pair l=\"%s\" r=\"%s\" v=\"%s\"/>\n", $postVal->[$_->{'left'}], $postVal->[$_->{'right'}], $_->{'kern'});
112 }
113 }
114
115
116 sub type
117 {
118 return 'kernOrderedList';
119 }
120
121
122 1;
123
124 =head1 BUGS
125
126 None known
127
128 =head1 AUTHOR
129
130 Jonathan Kew L<Jonathan_Kew@sil.org>. See L<PDF::API3::Compat::API2::Basic::TTF::Font> for copyright and
131 licensing.
132
133 =cut
134