blib/lib/TeX/XDV/Parse.pm

filter: Statementstmt 78.7% 74 / 94 Branchbran 43.7% 7 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 84.2% 16 / 19 Podpod 28.5% 2 / 7 totaltotal 70.9% 100 / 141 CC 10 SCAR 17.3
CC
10
Cov
73%
make_native_font_def
15.5
dir
6.0
make_glyph_thingy
2.0
CRAP 5.6
↑ Summary
1 package TeX::XDV::Parse;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 require TeX::DVI::Parse;
7  
8 3 $TeX::XDV::Parse::VERSION = '0.04';
9  
10 3 @TeX::XDV::Parse::ISA = qw/TeX::DVI::Parse/;
11  
12 3 @TeX::XDV::Parse::EXPORT_OK = qw(
13 XDV_FLAG_FONTTYPE_ATSUI
14 XDV_FLAG_FONTTYPE_ICU
15 XDV_FLAG_VERTICAL
16 XDV_FLAG_COLORED
17 XDV_FLAG_FEATURES
18 XDV_FLAG_VARIATIONS
19 XDV_FLAG_EXTEND
20 XDV_FLAG_SLANT
21 XDV_FLAG_EMBOLDEN
22 );
23  
24 3 %TeX::XDV::Parse::EXPORT_TAGS = (
25 'constants' => [qw/
26 XDV_FLAG_FONTTYPE_ATSUI
27 XDV_FLAG_FONTTYPE_ICU
28 XDV_FLAG_VERTICAL
29 XDV_FLAG_COLORED
30 XDV_FLAG_FEATURES
31 XDV_FLAG_VARIATIONS
32 XDV_FLAG_EXTEND
33 XDV_FLAG_SLANT
34 XDV_FLAG_EMBOLDEN
35 /],
36 );
37  
38 # from xdvipdfmx
39 # no hash interface before 5.8 for constant
40 3 ▶use constant XDV_FLAG_FONTTYPE_ATSUI => 0x0001;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 3 ▶use constant XDV_FLAG_FONTTYPE_ICU => 0x0002;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use constant XDV_FLAG_VERTICAL => 0x0100;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 3 ▶use constant XDV_FLAG_COLORED => 0x0200;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 3 ▶use constant XDV_FLAG_FEATURES => 0x0400;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 3 ▶use constant XDV_FLAG_VARIATIONS => 0x0800;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 3 ▶use constant XDV_FLAG_EXTEND => 0x1000;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 3 ▶use constant XDV_FLAG_SLANT => 0x2000;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 3 ▶use constant XDV_FLAG_EMBOLDEN => 0x4000;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 # Hmm.. either way we do this, the dispatcher in DVI::Parse
51 # sees the same thing. Either way, it ends up calling either
52 # DVI's handler or the one here. Since we're not trying to
53 # override anything, it doesn't really matter. The end result
54 # is the same as seen from the superclassing module.
55  
56 #our @COMMANDS;
57 #*COMMANDS = *TeX::DVI::Parse::COMMANDS;
58  
59 3 push @TeX::DVI::Parse::COMMANDS, (
60 # opcode 250 is still unused, as in TeX::DVI::Parse
61 [ 'pic_file', \&make_pic_file ], # 251
62 [ 'native_font_def', \&make_native_font_def ], # 252
63 [ 'glyph_array', \&make_glyph_array ], # 253
64 [ 'glyph_string', \&make_glyph_string ], # 254
65 [ 'dir', \&dir ], # 255
66 'undefined_command' # 256, not possible
67 );
68  
69 41 ▶sub make_glyph_string { make_glyph_thingy( 0, @_ ) }
Subroutine make_glyph_string: called CC=1 SCAR=0.0
Pod undocumented
70 0 ▶sub make_glyph_array { make_glyph_thingy( 1, @_ ) }
Subroutine make_glyph_array: not called CC=1 SCAR=6.9
Pod undocumented
71  
72 41 ▶sub make_glyph_thingy {
Subroutine make_glyph_thingy: called CC=2 SCAR=6.9
Pod undocumented
73 41 my $is_array = shift;
74 41 my $buff = pop @_;
75  
76 # width, count
77 41 my @list =
78 unpack "lna*",
79 pack "Lna*",
80 unpack "Nna*",
81 $buff;
82 41 $buff = pop @list;
83  
84 # locations, glyphs
85 41 my $c = $list[-1];
86 41 ▶ my $z = $is_array ? $c<<1 : $c;
Branch: 1 branch
BranchTrueFalseTotal
$is_array ? : 0 41 41
87 41 push @list,
88 unpack "l${z}n${c}a*",
89 pack "L${z}n${c}a*",
90 unpack "N${z}n${c}a*",
91 $buff;
92 41 $buff = pop @list;
93  
94 41 return @_, @list, $buff;
95 }
96  
97 3 ▶sub make_pic_file {
Subroutine make_pic_file: called CC=1 SCAR=0.0
Pod undocumented
98 3 my $buff = pop @_;
99 3 my @list =
100 unpack "CllllllsSa*",
101 pack "CLLLLLLSSa*",
102 unpack "CNNNNNNnna*",
103 $buff;
104 3 $buff = pop @list;
105 3 my $file;
106 3 ($file,$buff) = unpack "A$list[-1]a*", $buff;
107 3 return @_, @list, $file , $buff;
108 }
109  
110 4 ▶sub make_native_font_def {
Subroutine make_native_font_def: called CC=8 SCAR=27.4
Pod undocumented
111 4 my $buff = pop @_;
112  
113 # font_id, point_size, flags
114 4 my @list =
115 unpack "lLna*",
116 pack "LLna*",
117 unpack "NNna*",
118 $buff;
119 4 $buff = pop @list;
120  
121 4 my $f = $list[-1];
122  
123 4 ▶ die "invalid signature"
Branch: 1 branch
BranchTrueFalseTotal
unless $f & 2 or $f & 1 0 4 4
Condition33%1/3
$f & 2 or $f & 1
l!l&&r!l&&!r
400
MC/DC0%0/2
$f & 2 or $f & 1
$f & 2 $f & 1
Truth table33%1/3
A or B
A= $f & 2B= $f & 1
ABresult
1X1
011
000
124 unless $f & XDV_FLAG_FONTTYPE_ICU || $f & XDV_FLAG_FONTTYPE_ATSUI;
125  
126 # plen, flen, slen
127 4 push @list, unpack "CCCa*", $buff;
128 4 $buff = pop @list;
129  
130 # font_name, family_name, style_name
131 4 push @list, unpack "A$list[-3]A$list[-2]A$list[-1]a*", $buff;
132 4 $buff = pop @list;
133  
134 # rgba_color
135 4 ▶ if ($f & XDV_FLAG_COLORED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f & 512) 0 4 4
136 0 push @list, unpack "Na*", $buff;
137 0 $buff = pop @list;
138 }
139  
140 # variations
141 4 ▶ if ($f & XDV_FLAG_VARIATIONS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f & 2048) 0 4 4
142 0 push @list, unpack "na*", $buff;
143 0 $buff = pop @list;
144 0 my $n = $list[-1];
145 0 push @list,
146 unpack "l${n}N${n}a*", # need to make sure first is signed
147 pack "L${n}N${n}a*",
148 unpack "N${n}N${n}a*",
149 $buff;
150 0 $buff = pop @list;
151 }
152  
153 # extend ?
154 4 ▶ if ($f & XDV_FLAG_EXTEND) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f & 4096) 0 4 4
155 0 push @list,
156 unpack "la*",
157 pack "La*",
158 unpack "Na*",
159 $buff;
160 0 $buff = pop @list;
161 }
162  
163 # slant ?
164 4 ▶ if ($f & XDV_FLAG_SLANT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f & 8192) 0 4 4
165 0 push @list,
166 unpack "la*",
167 pack "La*",
168 unpack "Na*",
169 $buff;
170 0 $buff = pop @list;
171 }
172  
173 # bold ?
174 4 ▶ if ($f & XDV_FLAG_EMBOLDEN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f & 16384) 0 4 4
175 0 push @list,
176 unpack "la*",
177 pack "La*",
178 unpack "Na*",
179 $buff;
180 0 $buff = pop @list;
181 }
182  
183 4 return @_, @list, $buff;
184 }
185  
186 0 ▶sub dir {
Subroutine dir: not called CC=2 SCAR=17.9
Pod documented
187 0 my $buff = pop @_;
188 0 my @list = unpack "Ca*", $buff;
189 0 $buff = pop @list;
190 0 ▶ $list[-1] = $list[-1] ? 1 : 0; # 0=horizontal 1=vertical
Branch: 1 branch
BranchTrueFalseTotal
$list[-1] ? : 0 0 0
191 0 return @_, @list, $buff;
192 }
193  
194 0 ▶sub undefined_command {
Subroutine undefined_command: not called CC=1 SCAR=6.9
Pod documented
195 0 die "undefined_command: @_\n";
196 }
197  
198 3 1;
199  
200 __END__
↑ Summary