Font/TTF/Features/Cvar.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 48 CC 2 SCAR 11.5
CC
2
Cov
0%
out
6.0
read
2.0
new
2.0
CRAP 3.1
1 package Font::TTF::Features::Cvar;
2  
3 =head1 NAME
4  
5 Font::TTF::Features::Size - Class for Character Variants Feature Parameters
6  
7 =head1 DESCRIPTION
8  
9 Handles the Feature Parameters valus forCharacter Variants features
10  
11 =head1 INSTANCE VARIABLES
12  
13 =over 4
14  
15 =item INFILE
16  
17 The read file handle
18  
19 =item OFFSET
20  
21 Location of the file in the input file
22  
23 =item Format
24  
25 Table format - set to 0
26  
27 =item UINameID
28  
29 The 'name' table name ID that specifies a string (or strings, for multiple
30 languages) for a user-interface label for this feature
31  
32 =item TooltipNameID
33  
34 The 'name' table name ID for tooltip text for the feature
35  
36 =item SampleTextNameID
37  
38 The 'name' table name ID for sample text to illustrate the feature
39  
40 =item NumNamedParms
41  
42 The number of named parameters
43  
44 =item FirstNamedParmID
45  
46 The 'name' table name ID for the first named parameter
47  
48 =item Characters
49  
50 An array holding the unicode values of the characters for which the feature
51 provides glyph variants
52  
53 =back
54  
55 =head1 METHODS
56  
57 =cut
58  
59 use Font::TTF::Utils;
60 use strict;
61  
62 =head2 $t->read
63  
64 Reads the Feature Params
65  
66 =cut
67  
68 sub read
69 {
70 my ($self) = @_;
71 my ($fh) = $self->{' INFILE'};
72 my ($off) = $self->{' OFFSET'};
73 my ($dat, $i, $charcount);
74 $fh->seek($off, 0);
75 $fh->read($dat, 14);
76 ( $self->{'Format'}
77 ,$self->{'UINameID'}
78 ,$self->{'TooltipNameID'}
79 ,$self->{'SampleTextNameID'}
80 ,$self->{'NumNamedParm'}
81 ,$self->{'FirstNamedParmID'}
82 ,$charcount ) = TTF_Unpack("S*", $dat);
83  
84 # Now read the list of characters. Since these are 24bit insigned integers, need to
85 # read add a zero value byte to the front then treat as a 32bit integer
86  
87 foreach $i (0 .. $charcount-1)
88 {
89 $fh->read($dat,3);
90 $dat = pack("C","0") . $dat;
91 $self->{'Characters'}->[$i] = TTF_Unpack("L",$dat);
92 }
93
94 return $self;
95 }
96  
97 =head2 $t->out($fh)
98  
99 Writes the FeatureParams table to the output
100  
101 =cut
102  
103  
104  
105 sub out
106 {
107 my ($self, $fh) = @_;
108 my $chars = $self->{'Characters'};
109 my $charcount = 0;
110 if ($chars) { $charcount = scalar @{$chars} }
111 my ($dat, $i);
112
113 $fh->print(TTF_Pack("S*"
114 ,$self->{'Format'}
115 ,$self->{'UINameID'}
116 ,$self->{'TooltipNameID'}
117 ,$self->{'SampleTextNameID'}
118 ,$self->{'NumNamedParms'}
119 ,$self->{'FirstNamedParmID'}
120 ,$charcount ));
121
122 foreach $i ( 0 .. $charcount-1)
123 {
124 $dat = substr ( TTF_Pack("L",$chars->[$i]) ,1,3); # Pack as long then remove first byte to get UINT22
125 $fh->print($dat);
126 }
127
128 $self;
129 }
130  
131 =head2 Font::TTF::Features::Sset->new()
132  
133 Creates a new FeatureParams object.
134 Values for INFILE and OFFSET canbe passed as parameters
135  
136 =cut
137  
138 sub new
139 {
140 my ($class,%parms) = @_;
141 my ($self) = {};
142 my ($p);
143 foreach $p (keys %parms)
144 { $self->{" $p"} = $parms{$p}; }
145 bless $self, $class;
146 }
147  
148 sub out_xml
149 {
150 }
151  
152 1;
153  
154 =head1 AUTHOR
155  
156 David Raymond L<http://scripts.sil.org/FontUtils>.
157  
158 =head1 LICENSING
159  
160 Copyright (c) 1998-2016, SIL International (http://www.sil.org)
161  
162 This module is released under the terms of the Artistic License 2.0.
163 For details, see the full text of the license in the file LICENSE.
164  
165 =cut