lib/LaTeXML/Common/Font.pm

filter: Statementstmt 15.1% 59 / 390 Branchbran 0.0% 0 / 288 Conditioncond 0.0% 0 / 182 MC/DCmcdc 0.0% 0 / 106 Subroutinesub 18.8% 10 / 53 Podpod 9.5% 4 / 42 totaltotal 6.8% 73 / 1061 CC 212 SCAR 60.9
CC
212
Cov
7%
merge
1332.0
specialize
930.0
computeBoxesSize
703.9
CRAP 443.2
« lib/LaTeXML/Util/Pack.pm ↑ Summary lib/LaTeXML/Core/Mouth.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Common::Font | #
3 # | Representaion of Fonts | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> #_# | #
10 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
11 # \=========================================================ooo==U==ooo=/ #
12 package LaTeXML::Common::Font;
13 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use LaTeXML::Core::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use LaTeXML::Common::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use LaTeXML::Common::Dimension;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use List::Util qw(min max sum);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use base qw(LaTeXML::Common::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 # Note that this has evolved way beynond just "font",
24 # but covers text properties (or even display properties) in general
25 # including basic font information, color & background color
26 # as well as encoding and language information.
27  
28 5 DebuggableFeature('size-detailed', "Show sizing of boxes in detail");
29 # NOTE: This is now in Common that it may evolve to be useful in Post processing...
30  
31 5 my $DEFFAMILY = 'serif'; # [CONSTANT]
32 5 my $DEFSERIES = 'medium'; # [CONSTANT]
33 5 my $DEFSHAPE = 'upright'; # [CONSTANT]
34 5 my $DEFCOLOR = 'black'; # [CONSTANT]
35 5 my $DEFBACKGROUND = undef; # [CONSTANT] no color; transparent
36 5 my $DEFOPACITY = '1'; # [CONSTANT]
37 5 my $DEFENCODING = 'OT1'; # [CONSTANT]
38 5 my $DEFLANGUAGE = undef;
39  
40 0 ▶sub DEFSIZE { return $STATE->lookupValue('NOMINAL_FONT_SIZE') || 10; }
Subroutine DEFSIZE: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/2
$LaTeXML::Common::Font::STATE->lookupValue('NOMINAL_FONT_SIZE') || 10
l!l
00
MC/DC0%0/1
$LaTeXML::Common::Font::STATE->lookupValue('NOMINAL_FONT_SIZE') || 10
$LaTeXML::Common::Font::STATE->lookupValue('NOMINAL_FONT_SIZE')
Truth table0%0/2
A
A= $LaTeXML::Common::Font::STATE->lookupValue('NOMINAL_FONT_SIZE')
Aresult
11
00
41  
42 5 my $FLAG_FORCE_FAMILY = 0x1;
43 5 my $FLAG_FORCE_SERIES = 0x2;
44 5 my $FLAG_FORCE_SHAPE = 0x4;
45 5 my $FLAG_EMPH = 0x10;
46 #======================================================================
47 # Mappings from various forms of names or component names in TeX
48 # Given a font, we'd like to map it to the "logical" names derived from LaTeX,
49 # (w/ loss of fine grained control).
50 # I'd like to use Karl Berry's font naming scheme
51 # (See http://www.tug.org/fontname/html/)
52 # but it seems to be a one-way mapping, and moreover, doesn't even fit CM fonts!
53 # We'll assume a sloppier version:
54 # family + series + variant + size
55 # NOTE: This probably doesn't really belong in here...
56  
57 5 my %font_family = (
58 cmr => { family => 'serif' }, cmss => { family => 'sansserif' },
59 cmtt => { family => 'typewriter' }, cmvtt => { family => 'typewriter' },
60 cmti => { family => 'typewriter', shape => 'italic' },
61 cmfib => { family => 'serif' }, cmfr => { family => 'serif' },
62 cmdh => { family => 'serif' }, cm => { family => 'serif' },
63 ptm => { family => 'serif' }, ppl => { family => 'serif' },
64 pnc => { family => 'serif' }, pbk => { family => 'serif' },
65 phv => { family => 'sansserif' }, pag => { family => 'serif' },
66 pcr => { family => 'typewriter' }, pzc => { family => 'script' },
67 put => { family => 'serif' }, bch => { family => 'serif' },
68 psy => { family => 'symbol' }, pzd => { family => 'dingbats' },
69 ccr => { family => 'serif' }, ccy => { family => 'symbol' },
70 cmbr => { family => 'sansserif' }, cmtl => { family => 'typewriter' },
71 cmbrs => { family => 'symbol' }, ul9 => { family => 'typewriter' },
72 txr => { family => 'serif' }, txss => { family => 'sansserif' },
73 txtt => { family => 'typewriter' }, txms => { family => 'symbol' },
74 txsya => { family => 'symbol' }, txsyb => { family => 'symbol' },
75 pxr => { family => 'serif' }, pxms => { family => 'symbol' },
76 pxsya => { family => 'symbol' }, pxsyb => { family => 'symbol' },
77 futs => { family => 'serif' },
78 uaq => { family => 'serif' }, ugq => { family => 'sansserif' },
79 eur => { family => 'serif' }, eus => { family => 'script' },
80 euf => { family => 'fraktur' }, euex => { family => 'symbol' },
81 # The following are actually math fonts.
82 ms => { family => 'symbol' },
83 ccm => { family => 'serif', shape => 'italic' },
84 cmm => { family => 'italic', encoding => 'OML' },
85 cmex => { family => 'symbol', encoding => 'OMX' }, # Not really symbol, but...
86 cmsy => { family => 'symbol', encoding => 'OMS' },
87 ccitt => { family => 'typewriter', shape => 'italic' },
88 cmbrm => { family => 'sansserif', shape => 'italic' },
89 futm => { family => 'serif', shape => 'italic' },
90 futmi => { family => 'serif', shape => 'italic' },
91 txmi => { family => 'serif', shape => 'italic' },
92 pxmi => { family => 'serif', shape => 'italic' },
93 bbm => { family => 'blackboard' },
94 bbold => { family => 'blackboard' },
95 bbmss => { family => 'blackboard' },
96 # some ams fonts
97 cmmib => { family => 'italic', series => 'bold' },
98 cmbsy => { family => 'symbol', series => 'bold' },
99 msa => { family => 'symbol', encoding => 'AMSa' },
100 msb => { family => 'symbol', encoding => 'AMSb' },
101 # Are these really the same?
102 msx => { family => 'symbol', encoding => 'AMSa' },
103 msy => { family => 'symbol', encoding => 'AMSb' },
104 );
105  
106 # Maps the "series code" to an abstract font series name
107 5 my %font_series = (
108 '' => { series => 'medium' }, m => { series => 'medium' }, mc => { series => 'medium' },
109 b => { series => 'bold' }, bc => { series => 'bold' }, bx => { series => 'bold' },
110 sb => { series => 'bold' }, sbc => { series => 'bold' }, bm => { series => 'bold' });
111  
112 # Maps the "shape code" to an abstract font shape name.
113 5 my %font_shape = ('' => { shape => 'upright' }, n => { shape => 'upright' }, i => { shape => 'italic' }, it => { shape => 'italic' },
114 sl => { shape => 'slanted' }, sc => { shape => 'smallcaps' }, csc => { shape => 'smallcaps' });
115  
116 # These could be exported...
117 sub lookupFontFamily {
118 0 ▶ my ($familycode) = @_;
Subroutine lookupFontFamily: not called CC=1 SCAR=6.9
Pod undocumented
119 0 return $font_family{ ToString($familycode) }; }
120  
121 sub lookupFontSeries {
122 0 ▶ my ($seriescode) = @_;
Subroutine lookupFontSeries: not called CC=1 SCAR=6.9
Pod undocumented
123 0 return $font_series{ ToString($seriescode) }; }
124  
125 sub lookupFontShape {
126 0 ▶ my ($shapecode) = @_;
Subroutine lookupFontShape: not called CC=1 SCAR=6.9
Pod undocumented
127 0 return $font_shape{ ToString($shapecode) }; }
128  
129 # Symbolic font sizes, relative to the NOMINAL_FONT_SIZE (often 10)
130 # extended logical font sizes, based on nominal document size of 10pts
131 # Possibly should simply use absolute font point sizes, as declared in class...
132 5 my %font_size = (
133 tiny => 0.5, SMALL => 0.7, Small => 0.8, small => 0.9,
134 normal => 1.0, large => 1.2, Large => 1.44, LARGE => 1.728,
135 huge => 2.074, Huge => 2.488,
136 big => 1.2, Big => 1.6, bigg => 2.1, Bigg => 2.6,
137 );
138  
139 sub rationalizeFontSize {
140 0 ▶ my ($size) = @_;
Subroutine rationalizeFontSize: not called CC=3 SCAR=24.8
Pod undocumented
141 0 ▶ return unless defined $size;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 0 0
142 0 ▶ if (my $symbolic = $font_size{$size}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $symbolic = $font_size{$size}) 0 0 0
143 0 return $symbolic * DEFSIZE(); }
144 0 return $size; }
145  
146 # convert to percent
147 sub relativeFontSize {
148 0 ▶ my ($newsize, $oldsize) = @_;
Subroutine relativeFontSize: not called CC=1 SCAR=6.9
Pod undocumented
149 0 return int(0.5 + 100 * $newsize / $oldsize) . '%'; }
150  
151 my $FONTREGEXP
152 1521 = '(' . join('|', sort { -($a cmp $b) } keys %font_family) . ')'
153 103 . '(' . join('|', sort { -($a cmp $b) } keys %font_series) . ')'
154 5 . '(' . join('|', sort { -($a cmp $b) } keys %font_shape) . ')'
155 . '(\d*)';
156  
157 sub decodeFontname {
158 0 ▶ my ($name, $at, $scaled) = @_;
Subroutine decodeFontname: not called CC=10 SCAR=47.0
Pod undocumented
159 0 ▶ if ($name =~ /^$FONTREGEXP$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /^$FONTREGEXP$/o) { } 0 0 0
160 0 my %props;
161 0 my ($fam, $ser, $shp, $size) = ($1, $2, $3, $4);
162 0 ▶ if (my $ffam = lookupFontFamily($fam)) { map { $props{$_} = $$ffam{$_} } keys %$ffam; }
Branch: 1 branch
BranchTrueFalseTotal
if (my $ffam = lookupFontFamily($fam)) 0 0 0
163 0 ▶ if (my $fser = lookupFontSeries($ser)) { map { $props{$_} = $$fser{$_} } keys %$fser; }
Branch: 1 branch
BranchTrueFalseTotal
if (my $fser = lookupFontSeries($ser)) 0 0 0
164 0 ▶ if (my $fsh = lookupFontShape($shp)) { map { $props{$_} = $$fsh{$_} } keys %$fsh; }
Branch: 1 branch
BranchTrueFalseTotal
if (my $fsh = lookupFontShape($shp)) 0 0 0
165 0 ▶ $size = 1 unless $size; # Yes, also if 0, "" (from regexp)
Branch: 1 branch
BranchTrueFalseTotal
unless $size 0 0 0
166 0 ▶ $size = $at if defined $at;
Branch: 1 branch
BranchTrueFalseTotal
if defined $at 0 0 0
167 0 ▶ $size *= $scaled if defined $scaled;
Branch: 1 branch
BranchTrueFalseTotal
if defined $scaled 0 0 0
168 0 $props{size} = $size;
169 # Experimental Hack !?!?!?
170 0 ▶ $props{encoding} = 'OT1' unless defined $props{encoding};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props{"encoding"} 0 0 0
171 0 ▶ $props{at} = $at . "pt" if defined $at;
Branch: 1 branch
BranchTrueFalseTotal
if defined $at 0 0 0
172 0 return %props; }
173 else {
174 0 return; } }
175  
176 sub lookupTeXFont {
177 0 ▶ my ($fontname, $seriescode, $shapecode) = @_;
Subroutine lookupTeXFont: not called CC=4 SCAR=30.0
Pod undocumented
178 0 my %props;
179 0 ▶ if (my $ffam = lookupFontFamily($fontname)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ffam = lookupFontFamily($fontname)) 0 0 0
180 0 map { $props{$_} = $$ffam{$_} } keys %$ffam; }
181 0 ▶ if (my $fser = lookupFontSeries($seriescode)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fser = lookupFontSeries($seriescode)) 0 0 0
182 0 map { $props{$_} = $$fser{$_} } keys %$fser; }
183 0 ▶ if (my $fsh = lookupFontShape($shapecode)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fsh = lookupFontShape($shapecode)) 0 0 0
184 0 map { $props{$_} = $$fsh{$_} } keys %$fsh; }
185 0 return %props; }
186  
187 #======================================================================
188 # NOTE: Would it make sense to allow compnents to be `inherit' ??
189  
190 # Note: forcefamily, forceseries, forceshape (& forcebold for compatibility)
191 # are only useful for fonts in math; See the specialize method below.
192 sub new {
193 0 ▶ my ($class, %options) = @_;
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
194 0 my $family = $options{family};
195 0 my $series = $options{series};
196 0 my $shape = $options{shape};
197 0 my $size = $options{size};
198 0 my $color = $options{color};
199 0 my $bg = $options{background};
200 0 my $opacity = $options{opacity};
201 0 my $encoding = $options{encoding};
202 0 my $language = $options{language};
203 0 my $mathstyle = $options{mathstyle};
204  
205 0 ▶ if ($options{forcebold}) { # for compatibility
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"forcebold"}) 0 0 0
206 0 $series = 'bold'; $options{forceseries} = 1; }
207 my $flags = 0
208 | ($options{forcefamily} ? $FLAG_FORCE_FAMILY : 0)
209 | ($options{forceseries} ? $FLAG_FORCE_SERIES : 0)
210 0 ▶ | ($options{forceshape} ? $FLAG_FORCE_SHAPE : 0);
Branch: 3 branches
BranchTrueFalseTotal
$options{'forcefamily'} ? : 0 0 0
$options{'forceseries'} ? : 0 0 0
$options{'forceshape'} ? : 0 0 0
211 0 return $class->new_internal(
212 $family, $series, $shape, rationalizeFontSize($size),
213 $color, $bg, $opacity,
214 $encoding, $language,
215 $mathstyle, $flags); }
216  
217 sub new_internal {
218 0 ▶ my ($class, @components) = @_;
Subroutine new_internal: not called CC=1 SCAR=6.9
Pod undocumented
219 0 return bless [@components], $class; }
220  
221 sub textDefault {
222 0 ▶ my ($self) = @_;
Subroutine textDefault: not called CC=1 SCAR=6.9
Pod undocumented
223 0 return $self->new_internal($DEFFAMILY, $DEFSERIES, $DEFSHAPE, DEFSIZE(),
224 $DEFCOLOR, $DEFBACKGROUND, $DEFOPACITY, $DEFENCODING, $DEFLANGUAGE, undef, 0); }
225  
226 sub mathDefault {
227 0 ▶ my ($self) = @_;
Subroutine mathDefault: not called CC=1 SCAR=6.9
Pod undocumented
228 0 return $self->new_internal('math', $DEFSERIES, 'italic', DEFSIZE(),
229 $DEFCOLOR, $DEFBACKGROUND, $DEFOPACITY, undef, $DEFLANGUAGE, 'text', 0); }
230  
231 # Accessors
232 # Using an array here is getting ridiculous!
233 0 ▶sub getFamily { my ($self) = @_; return $$self[0]; }
Subroutine getFamily: not called CC=1 SCAR=6.9
Pod undocumented
234 0 ▶sub getSeries { my ($self) = @_; return $$self[1]; }
Subroutine getSeries: not called CC=1 SCAR=6.9
Pod undocumented
235 0 ▶sub getShape { my ($self) = @_; return $$self[2]; }
Subroutine getShape: not called CC=1 SCAR=6.9
Pod undocumented
236 0 ▶sub getSize { my ($self) = @_; return $$self[3]; }
Subroutine getSize: not called CC=1 SCAR=6.9
Pod undocumented
237 0 ▶sub getColor { my ($self) = @_; return $$self[4]; }
Subroutine getColor: not called CC=1 SCAR=6.9
Pod undocumented
238 0 ▶sub getBackground { my ($self) = @_; return $$self[5]; }
Subroutine getBackground: not called CC=1 SCAR=6.9
Pod undocumented
239 0 ▶sub getOpacity { my ($self) = @_; return $$self[6]; }
Subroutine getOpacity: not called CC=1 SCAR=6.9
Pod undocumented
240 0 ▶sub getEncoding { my ($self) = @_; return $$self[7]; }
Subroutine getEncoding: not called CC=1 SCAR=6.9
Pod undocumented
241 0 ▶sub getLanguage { my ($self) = @_; return $$self[8]; }
Subroutine getLanguage: not called CC=1 SCAR=6.9
Pod undocumented
242 0 ▶sub getMathstyle { my ($self) = @_; return $$self[9]; }
Subroutine getMathstyle: not called CC=1 SCAR=6.9
Pod undocumented
243 0 ▶sub getFlags { my ($self) = @_; return $$self[10]; }
Subroutine getFlags: not called CC=1 SCAR=6.9
Pod undocumented
244  
245 sub toString {
246 0 ▶ my ($self) = @_;
Subroutine toString: not called CC=2 SCAR=17.9
Pod documented
247 0 ▶ return "Font[" . join(',', map { (defined $_ ? ToString($_) : '*') } @{$self}) . "]"; }
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
248  
249 # Perhaps it is more useful to list only the non-default components?
250 sub stringify {
251 0 ▶ my ($self) = @_;
Subroutine stringify: not called CC=12 SCAR=50.5
Pod documented
252 0 my ($fam, $ser, $shp, $siz, $col, $bkg, $opa, $enc, $lang, $mstyle, $flags) = @$self;
253 0 ▶ $fam = 'serif' if $fam && ($fam eq 'math');
Branch: 1 branch
BranchTrueFalseTotal
if $fam and $fam eq "math" 0 0 0
Condition0%0/3
$fam and $fam eq "math"
!ll&&!rl&&r
000
MC/DC0%0/2
$fam and $fam eq "math"
$fam $fam eq "math"
Truth table0%0/3
A and B
A= $famB= $fam eq "math"
ABresult
0X0
100
111
254 0 ▶ return 'Font[' . join(',', map { Stringify($_) } grep { $_ }
Branch: 9 branches
BranchTrueFalseTotal
isDiff($fam, $DEFFAMILY) ? : 0 0 0
isDiff($ser, $DEFSERIES) ? : 0 0 0
isDiff($shp, $DEFSHAPE) ? : 0 0 0
isDiff($siz, DEFSIZE()) ? : 0 0 0
isDiff($col, $DEFCOLOR) ? : 0 0 0
isDiff($bkg, $DEFBACKGROUND) ? : 0 0 0
isDiff($opa, $DEFOPACITY) ? : 0 0 0
$mstyle ? : 0 0 0
$flags ? : 0 0 0
255 (isDiff($fam, $DEFFAMILY) ? ($fam) : ()),
256 (isDiff($ser, $DEFSERIES) ? ($ser) : ()),
257 (isDiff($shp, $DEFSHAPE) ? ($shp) : ()),
258 (isDiff($siz, DEFSIZE()) ? ($siz) : ()),
259 (isDiff($col, $DEFCOLOR) ? ($col) : ()),
260 (isDiff($bkg, $DEFBACKGROUND) ? ($bkg) : ()),
261 (isDiff($opa, $DEFOPACITY) ? ($opa) : ()),
262 ($mstyle ? ($mstyle) : ()),
263 ($flags ? ($flags) : ()),
264 )
265 . ']'; }
266  
267 sub equals {
268 0 ▶ my ($self, $other) = @_;
Subroutine equals: not called CC=5 SCAR=34.0
Pod documented
269 return (defined $other) && ((ref $self) eq (ref $other))
270 0 ▶ && (join('|', map { (defined $_ ? $_ : '*') } @$self)
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
271 0 ▶ eq join('|', map { (defined $_ ? $_ : '*') } @$other)); }
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
Condition0%0/6
defined $other && ref $self eq ref $other && join('|', map({defined $_ ? $_ : '*';} @$self)) eq join('|', map({defined $_ ? $_ : '*';} @$other))
!ll&&!rl&&r
000
defined $other and ref $self eq ref $other
!ll&&!rl&&r
000
MC/DC0%0/3
defined $other && ref $self eq ref $other && join('|', map({defined $_ ? $_ : '*';} @$self)) eq join('|', map({defined $_ ? $_ : '*';} @$other))
defined $other ref $self eq ref $other join('|', map({defined $_ ? $_ : '*';} @$self)) eq join('|', map({defined $_ ? $_ : '*';} @$other))
Truth table0%0/4
A and B && C
A= defined $otherB= ref $self eq ref $otherC= join('|', map({defined $_ ? $_ : '*';} @$self)) eq join('|', map({defined $_ ? $_ : '*';} @$other))
ABCresult
0XX0
10X0
1100
1111
272  
273 sub match {
274 0 ▶ my ($self, $other) = @_;
Subroutine match: not called CC=7 SCAR=40.3
Pod undocumented
275 0 ▶ return 1 unless defined $other;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 0 0
276 0 ▶ return 0 unless (ref $self) eq (ref $other);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self eq ref $other 0 0 0
277 0 my @comp = @$self;
278 0 my @ocomp = @$other;
279 # If any components are defined in both fonts, they must be equal.
280 0 ▶ while (@comp) {
Branch: 1 branch
BranchTrueFalseTotal
if (@comp) 0 0 0
281 0 my $c = shift @comp;
282 0 my $oc = shift @ocomp;
283 0 ▶ return 0 if (defined $c) && (defined $oc) && ($c ne $oc); }
Branch: 1 branch
BranchTrueFalseTotal
if defined $c and defined $oc and $c ne $oc 0 0 0
Condition0%0/6
defined $c and defined $oc and $c ne $oc
!ll&&!rl&&r
000
defined $c and defined $oc
!ll&&!rl&&r
000
MC/DC0%0/3
defined $c and defined $oc and $c ne $oc
defined $c defined $oc $c ne $oc
Truth table0%0/4
A and B and C
A= defined $cB= defined $ocC= $c ne $oc
ABCresult
0XX0
10X0
1100
1111
284 0 return 1; }
285  
286 sub makeConcrete {
287 0 ▶ my ($self, $concrete) = @_;
Subroutine makeConcrete: not called CC=13 SCAR=52.0
Pod undocumented
288 0 my ($family, $series, $shape, $size, $color, $bg, $opacity, $encoding, $lang, $mstyle, $flags) = @$self;
289 0 my ($ofamily, $oseries, $oshape, $osize, $ocolor, $obg, $oopacity, $oencoding, $olang, $omstyle, $oflags) = @$concrete;
290 0 ▶ return (ref $self)->new_internal(
Branch: 1 branch
BranchTrueFalseTotal
defined $opacity ? : 0 0 0
Condition0%0/31
$family || $ofamily
l!l&&r!l&&!r
000
$series || $oseries
l!l&&r!l&&!r
000
$shape || $oshape
l!l&&r!l&&!r
000
$size || $osize
l!l&&r!l&&!r
000
$color || $ocolor
l!l&&r!l&&!r
000
$bg || $obg
l!l&&r!l&&!r
000
$encoding || $oencoding
l!l&&r!l&&!r
000
$lang || $olang
l!l&&r!l&&!r
000
$mstyle || $omstyle
l!l&&r!l&&!r
000
$flags || 0
l!l
00
$oflags || 0
l!l
00
MC/DC0%0/2
$family || $ofamily
$family $ofamily
MC/DC0%0/2
$series || $oseries
$series $oseries
MC/DC0%0/2
$shape || $oshape
$shape $oshape
MC/DC0%0/2
$size || $osize
$size $osize
MC/DC0%0/2
$color || $ocolor
$color $ocolor
MC/DC0%0/2
$bg || $obg
$bg $obg
MC/DC0%0/2
$encoding || $oencoding
$encoding $oencoding
MC/DC0%0/2
$lang || $olang
$lang $olang
MC/DC0%0/2
$mstyle || $omstyle
$mstyle $omstyle
MC/DC0%0/1
$flags || 0
$flags
MC/DC0%0/1
$oflags || 0
$oflags
Truth table0%0/3
A || B
A= $familyB= $ofamily
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $seriesB= $oseries
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $shapeB= $oshape
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $sizeB= $osize
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $colorB= $ocolor
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $bgB= $obg
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $encodingB= $oencoding
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $langB= $olang
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $mstyleB= $omstyle
ABresult
1X1
011
000
Truth table0%0/2
A
A= $flags
Aresult
11
00
Truth table0%0/2
A
A= $oflags
Aresult
11
00
291 $family || $ofamily, $series || $oseries, $shape || $oshape, $size || $osize,
292 $color || $ocolor, $bg || $obg, (defined $opacity ? $opacity : $oopacity),
293 $encoding || $oencoding, $lang || $olang, $mstyle || $omstyle,
294 ($flags || 0) | ($oflags || 0)); }
295  
296 sub isDiff {
297 0 ▶ my ($x, $y) = @_;
Subroutine isDiff: not called CC=3 SCAR=24.8
Pod undocumented
298 0 ▶ return (defined $x) && (!(defined $y) || ($x ne $y)); }
Condition0%0/6
defined $x && (!defined($y) || $x ne $y)
!ll&&!rl&&r
000
not defined $y or $x ne $y
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $x && (!defined($y) || $x ne $y)
defined $x not defined $y $x ne $y
Truth table0%0/4
A && not(B) or C
A= defined $xB= not defined $yC= $x ne $y
ABCresult
0XX0
1000
11X1
1011
299  
300 # This method compares 2 fonts, returning the differences between them.
301 # Noting that the font-related attributes in the schema distill the
302 # font properties into fewer attributes (font,fontsize,color,background,opacity),
303 # the return value encodes both the attribute changes that would be needed to effect
304 # the font change, along with the font properties that differed
305 # Namely, the result is a hash keyed on the attribute name and whose value is a hash
306 # value => "new_attribute_value"
307 # properties => { %fontproperties }
308 # Note in particular 2 interesting keys
309 # element: can specify the element tagname to use for wrapping instead of ltx:text
310 # class: can be used to add a class attribute to the wrapping element
311 sub relativeTo {
312 0 ▶ my ($self, $other) = @_;
Subroutine relativeTo: not called CC=22 SCAR=62.3
Pod undocumented
313 0 my ($fam, $ser, $shp, $siz, $col, $bkg, $opa, $enc, $lang, $mstyle, $flags) = @$self;
314 0 my ($ofam, $oser, $oshp, $osiz, $ocol, $obkg, $oopa, $oenc, $olang, $omstyle, $oflags) = @$other;
315 0 ▶ $fam = 'serif' if $fam && ($fam eq 'math');
Branch: 1 branch
BranchTrueFalseTotal
if $fam and $fam eq "math" 0 0 0
Condition0%0/3
$fam and $fam eq "math"
!ll&&!rl&&r
000
MC/DC0%0/2
$fam and $fam eq "math"
$fam $fam eq "math"
Truth table0%0/3
A and B
A= $famB= $fam eq "math"
ABresult
0X0
100
111
316 0 ▶ $ofam = 'serif' if $ofam && ($ofam eq 'math');
Branch: 1 branch
BranchTrueFalseTotal
if $ofam and $ofam eq "math" 0 0 0
Condition0%0/3
$ofam and $ofam eq "math"
!ll&&!rl&&r
000
MC/DC0%0/2
$ofam and $ofam eq "math"
$ofam $ofam eq "math"
Truth table0%0/3
A and B
A= $ofamB= $ofam eq "math"
ABresult
0X0
100
111
317 ## my $emph = 0;
318 ## $emph ||= $shp && $shp =~ s/^emph-//;
319 ## ## $emph ||= $oshp && $oshp =~ s/^emph-//;
320 ## $oshp && $oshp =~ s/^emph-//;
321 0 ▶ my @diffs = (
Branch: 3 branches
BranchTrueFalseTotal
isDiff($fam, $ofam) ? : 0 0 0
isDiff($ser, $oser) ? : 0 0 0
isDiff($shp, $oshp) ? : 0 0 0
322 (isDiff($fam, $ofam) ? ($fam) : ()),
323 (isDiff($ser, $oser) ? ($ser) : ()),
324 (isDiff($shp, $oshp) ? ($shp) : ()));
325 return (
326 0 ▶ (@diffs ?
Branch: 10 branches
BranchTrueFalseTotal
@diffs ? : 0 0 0
isDiff($fam, $ofam) ? : 0 0 0
isDiff($ser, $oser) ? : 0 0 0
isDiff($shp, $oshp) ? : 0 0 0
isDiff($siz, $osiz) ? : 0 0 0
isDiff($col, $ocol) ? : 0 0 0
isDiff($bkg, $obkg) ? : 0 0 0
isDiff($opa, $oopa) ? : 0 0 0
isDiff($lang, $olang) ? : 0 0 0
!$mstyle && $flags && $flags & $FLAG_EMPH && !($oflags && $oflags & $FLAG_EMPH) ? : 0 0 0
Condition0%0/12
not $mstyle and $flags and $flags & $FLAG_EMPH and not $oflags && $oflags & $FLAG_EMPH
!ll&&!rl&&r
000
not $mstyle and $flags and $flags & $FLAG_EMPH
!ll&&!rl&&r
000
not $mstyle and $flags
!ll&&!rl&&r
000
$oflags && $oflags & $FLAG_EMPH
!ll&&!rl&&r
000
MC/DC0%0/5
not $mstyle and $flags and $flags & $FLAG_EMPH and not $oflags && $oflags & $FLAG_EMPH
not $mstyle $flags $flags & $FLAG_EMPH $oflags $oflags & $FLAG_EMPH
Truth table0%0/6
not(A) and B and C and not(D && E)
A= not $mstyleB= $flagsC= $flags & $FLAG_EMPHD= $oflagsE= $oflags & $FLAG_EMPH
ABCDEresult
0XXXX0
10XXX0
110XX0
111110
1110X1
111101
327 (font => { value => join(' ', @diffs),
328 properties => { (isDiff($fam, $ofam) ? (family => $fam) : ()),
329 (isDiff($ser, $oser) ? (series => $ser) : ()),
330 (isDiff($shp, $oshp) ? (shape => $shp) : ()) } })
331 : ()),
332 (isDiff($siz, $osiz)
333 ### ? (fontsize => { value => $siz, properties => { size => $siz } })
334 ? (fontsize => { value => relativeFontSize($siz, $osiz), properties => { size => $siz } })
335 : ()),
336 (isDiff($col, $ocol)
337 ? (color => { value => $col, properties => { color => $col } })
338 : ()),
339 (isDiff($bkg, $obkg)
340 ? (backgroundcolor => { value => $bkg, properties => { background => $bkg } })
341 : ()),
342 (isDiff($opa, $oopa)
343 ? (opacity => { value => $opa, properties => { opacity => $opa } })
344 : ()),
345 (isDiff($lang, $olang)
346 ? ('xml:lang' => { value => $lang, properties => { language => $lang } })
347 : ()),
348 (!$mstyle && $flags && ($flags & $FLAG_EMPH) && (!$oflags || !($oflags & $FLAG_EMPH))
349 ? (
350 # class => { value => 'ltx_emph' },
351 element => { value => 'ltx:emph' }
352 )
353 : ()),
354 ### Contemplate this: We do NOT want mathstyle showing up (automatically) in the attributes
355 ### So, we presumably want to ignore differences in mathstyle
356 ### They shouldn't (by themselves) affect the display?
357 ### (isDiff($mstyle, $omstyle)
358 ### ? ('mathstyle' => { value => $mstyle, properties => { mathstyle => $mstyle } })
359 ### : ()),
360 ); }
361  
362 sub distance {
363 0 ▶ my ($self, $other) = @_;
Subroutine distance: not called CC=14 SCAR=53.5
Pod undocumented
364 0 my ($fam, $ser, $shp, $siz, $col, $bkg, $opa, $enc, $lang, $mstyle, $flags) = @$self;
365 0 my ($ofam, $oser, $oshp, $osiz, $ocol, $obkg, $oopa, $oenc, $olang, $omstyle, $oflags) = @$other;
366 0 ▶ $fam = 'serif' if $fam && ($fam eq 'math');
Branch: 1 branch
BranchTrueFalseTotal
if $fam and $fam eq "math" 0 0 0
Condition0%0/3
$fam and $fam eq "math"
!ll&&!rl&&r
000
MC/DC0%0/2
$fam and $fam eq "math"
$fam $fam eq "math"
Truth table0%0/3
A and B
A= $famB= $fam eq "math"
ABresult
0X0
100
111
367 0 ▶ $ofam = 'serif' if $ofam && ($ofam eq 'math');
Branch: 1 branch
BranchTrueFalseTotal
if $ofam and $ofam eq "math" 0 0 0
Condition0%0/3
$ofam and $ofam eq "math"
!ll&&!rl&&r
000
MC/DC0%0/2
$ofam and $ofam eq "math"
$ofam $ofam eq "math"
Truth table0%0/3
A and B
A= $ofamB= $ofam eq "math"
ABresult
0X0
100
111
368 return
369 0 ▶ (isDiff($fam, $ofam) ? 1 : 0)
Branch: 9 branches
BranchTrueFalseTotal
isDiff($fam, $ofam) ? : 0 0 0
isDiff($ser, $oser) ? : 0 0 0
isDiff($shp, $oshp) ? : 0 0 0
isDiff($siz, $osiz) ? : 0 0 0
isDiff($col, $ocol) ? : 0 0 0
isDiff($bkg, $obkg) ? : 0 0 0
isDiff($opa, $oopa) ? : 0 0 0
isDiff($lang, $olang) ? : 0 0 0
$flags & $FLAG_EMPH ^ $oflags & $FLAG_EMPH ? : 0 0 0
370 + (isDiff($ser, $oser) ? 1 : 0)
371 + (isDiff($shp, $oshp) ? 1 : 0)
372 + (isDiff($siz, $osiz) ? 1 : 0)
373 + (isDiff($col, $ocol) ? 1 : 0)
374 + (isDiff($bkg, $obkg) ? 1 : 0)
375 + (isDiff($opa, $oopa) ? 1 : 0)
376 ## + (isDiff($enc,$oenc) ? 1 : 0)
377 + (isDiff($lang, $olang) ? 1 : 0)
378 # Let's not consider mathstyle differences here, either.
379 ### + (isDiff($mstyle, $omstyle) ? 1 : 0)
380 + (($flags & $FLAG_EMPH) ^ ($oflags & $FLAG_EMPH) ? 1 : 0)
381 ; }
382  
383 # This matches fonts when both are converted to strings (toString),
384 # such as when they are set as attributes.
385 # This accumulates regular expressions used by match_font
386 # (which, in turn, is used in various XPath searches!)
387 # It is NOT really Daemon safe....
388 # Need to work out how to do this and/or cache it in STATE????
389 5 our %FONT_REGEXP_CACHE = ();
390  
391 sub match_font {
392 0 ▶ my ($font1, $font2) = @_;
Subroutine match_font: not called CC=4 SCAR=30.0
Pod undocumented
393 0 my $regexp = $FONT_REGEXP_CACHE{$font1};
394 0 ▶ if (!$regexp) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($regexp) 0 0 0
395 0 ▶ if ($font1 =~ /^Font\[(.*)\]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($font1 =~ /^Font\[(.*)\]$/) 0 0 0
396 0 my @comp = split(',', $1);
397 my $re = '^Font\['
398 0 ▶ . join(',', map { ($_ eq '*' ? "[^,]+" : "\Q$_\E") } @comp)
Branch: 1 branch
BranchTrueFalseTotal
$_ eq '*' ? : 0 0 0
399 . '\]$';
400 0 $regexp = $FONT_REGEXP_CACHE{$font1} = qr/$re/; } }
401 0 return $font2 =~ /$regexp/; }
402  
403 sub XXXfont_match_xpaths {
404 0 ▶ my ($font) = @_;
Subroutine XXXfont_match_xpaths: not called CC=9 SCAR=45.0
Pod undocumented
405 0 ▶ if ($font =~ /^Font\[(.*)\]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($font =~ /^Font\[(.*)\]$/) 0 0 0
406 0 my @comps = split(',', $1);
407 0 my ($frag, @frags) = ();
408 0 ▶ for (my $i = 0 ; $i <= $#comps ; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#comps) 0 0 0
409 0 my $comp = $comps[$i];
410 0 ▶ if ($comp eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp eq '*') { } 0 0 0
411 0 ▶ push(@frags, $frag) if $frag;
Branch: 1 branch
BranchTrueFalseTotal
if $frag 0 0 0
412 0 $frag = undef; }
413 else {
414 0 ▶ my $post = ($i == $#comps ? ']' : ',');
Branch: 1 branch
BranchTrueFalseTotal
$i == $#comps ? : 0 0 0
415 0 ▶ if ($frag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frag) { } 0 0 0
416 0 $frag .= $comp . $post; }
417 else {
418 0 ▶ $frag = ($i == 0 ? 'Font[' : ',') . $comp . $post; } } }
Branch: 1 branch
BranchTrueFalseTotal
$i == 0 ? : 0 0 0
419 0 ▶ push(@frags, $frag) if $frag;
Branch: 1 branch
BranchTrueFalseTotal
if $frag 0 0 0
420 return join(' and ', '@_font',
421 0 map { "contains(\@_font,'$_')" } @frags); } }
422  
423 sub font_match_xpaths {
424 0 ▶ my ($font) = @_;
Subroutine font_match_xpaths: not called CC=5 SCAR=34.0
Pod undocumented
425 0 ▶ if ($font =~ /^Font\[(.*)\]$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($font =~ /^Font\[(.*)\]$/) 0 0 0
426 0 my ($family, $series, $shape, $size, $color, $bg, $opacity, $encoding, $language,
427 $mstyle, $force) = split(',', $1);
428 # Ignore differences in:
429 # size, background, opacity, encoding, language(?), mathstyle,
430 # force bits assumed NOT relevant, also.
431 # For now, ignore color, too
432 0 my @frags = ();
433 0 ▶ push(@frags, '[' . $family . ',') if ($family ne '*');
Branch: 1 branch
BranchTrueFalseTotal
if $family ne "*" 0 0 0
434 0 ▶ push(@frags, ',' . $series . ',') if ($series ne '*');
Branch: 1 branch
BranchTrueFalseTotal
if $series ne "*" 0 0 0
435 0 ▶ push(@frags, ',' . $shape . ',') if ($shape ne '*');
Branch: 1 branch
BranchTrueFalseTotal
if $shape ne "*" 0 0 0
436 # push(@frags, ',' . $color . ',') if ($color ne '*');
437 return join(' and ', '@_font',
438 0 map { "contains(\@_font,'$_')" } @frags); } }
439  
440 # # Presumably a text font is "sticky", if used in math?
441 # sub isSticky { return 1; }
442  
443 #======================================================================
444 5 our %mathstylesize = (display => 1, text => 1,
445 script => 0.7, scriptscript => 0.5);
446  
447 # NOTE: that we assume the size has already been adjusted for mathstyle, if necessary.
448 sub computeStringSize {
449 0 ▶ my ($self, $string) = @_;
Subroutine computeStringSize: not called CC=7 SCAR=40.3
Pod undocumented
450 0 ▶ if ((!defined $string) || ($string eq '') || ($self->getFamily eq 'nullfont')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $string or $string eq "" or $self->getFamily eq "nullfont") 0 0 0
Condition0%0/6
not defined $string or $string eq "" or $self->getFamily eq "nullfont"
l!l&&r!l&&!r
000
not defined $string or $string eq ""
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $string or $string eq "" or $self->getFamily eq "nullfont"
not defined $string $string eq "" $self->getFamily eq "nullfont"
Truth table0%0/4
not(A) or B or C
A= not defined $stringB= $string eq ""C= $self->getFamily eq "nullfont"
ABCresult
1XX1
01X1
0011
0000
451 0 return (Dimension(0), Dimension(0), Dimension(0)); }
452 0 ▶ my $size = ($self->getSize || DEFSIZE() || 10); ## * $mathstylesize{ $self->getMathstyle || 'text' };
Condition0%0/5
$self->getSize || DEFSIZE() || 10
l!l
00
$self->getSize or DEFSIZE()
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->getSize || DEFSIZE() || 10
$self->getSize DEFSIZE()
Truth table0%0/3
A or B
A= $self->getSizeB= DEFSIZE()
ABresult
1X1
011
000
453 0 ▶ my $l = (defined $string ? length($string) : 0);
Branch: 1 branch
BranchTrueFalseTotal
defined $string ? : 0 0 0
454 0 my $u = $size * 65535;
455 0 return (Dimension(0.75 * $u * $l), Dimension(0.7 * $u), Dimension(0.2 * $u)); }
456  
457 # Get nominal width, height base ?
458 sub getNominalSize {
459 0 ▶ my ($self) = @_;
Subroutine getNominalSize: not called CC=3 SCAR=24.8
Pod undocumented
460 0 ▶ my $size = ($self->getSize || DEFSIZE() || 10); ## * $mathstylesize{ $self->getMathstyle || 'text' };
Condition0%0/5
$self->getSize || DEFSIZE() || 10
l!l
00
$self->getSize or DEFSIZE()
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->getSize || DEFSIZE() || 10
$self->getSize DEFSIZE()
Truth table0%0/3
A or B
A= $self->getSizeB= DEFSIZE()
ABresult
1X1
011
000
461 0 my $u = $size * 65535;
462 0 return (Dimension(0.75 * $u), Dimension(0.7 * $u), Dimension(0.2 * $u)); }
463  
464 # Here's where I avoid trying to emulate Knuth's line-breaking...
465 # Mostly for List & Whatsit: compute the size of a list of boxes.
466 # Options _SHOULD_ include:
467 # width: if given, pretend to simulate line breaking to that width
468 # height,depth : ?
469 # vattach : top, bottom, center, baseline (...?) affects how the height & depth are
470 # allocated when there are multiple lines.
471 # layout : horizontal or vertical !!!
472 # Boxes that arent a Core Box, List, Whatsit or a string are IGNORED
473 #
474 # The big problem with width is to have it propogate down from where
475 # it may have been specified to the actual nested box that will get wrapped!
476 # Try to mask this (temporarily) by unlisting, and (pretending to ) breaking up too wide items
477 #
478 # Another issue; SVG needs (sometimes) real sizes, even if the programmer
479 # set some dimensions to 0 (eg.) We may need to distinguish & store
480 # requested vs real sizes?
481 sub computeBoxesSize {
482 0 ▶ my ($self, $boxes, %options) = @_;
Subroutine computeBoxesSize: not called CC=27 SCAR=65.6
Pod undocumented
483 0 ▶ my $font = (ref $self ? $self : $STATE->lookupValue('font'));
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 0 0 0
484 0 my $fillwidth = $options{width};
485 0 ▶ if ((!defined $fillwidth) && ($fillwidth = $STATE->lookupDefinition(T_CS('\textwidth')))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $fillwidth and $fillwidth = $LaTeXML::Common::Font::STATE->lookupDefinition(T_CS("\\textwidth"))) 0 0 0
Condition0%0/3
not defined $fillwidth and $fillwidth = $LaTeXML::Common::Font::STATE->lookupDefinition(T_CS("\\textwidth"))
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $fillwidth and $fillwidth = $LaTeXML::Common::Font::STATE->lookupDefinition(T_CS("\\textwidth"))
not defined $fillwidth $fillwidth = $LaTeXML::Common::Font::STATE->lookupDefinition(T_CS("\\textwidth"))
Truth table0%0/3
not(A) and B
A= not defined $fillwidthB= $fillwidth = $LaTeXML::Common::Font::STATE->lookupDefinition(T_CS("\\textwidth"))
ABresult
0X0
100
111
486 0 $fillwidth = $fillwidth->valueOf; } # get register
487 0 ▶ my $maxwidth = $fillwidth && $fillwidth->valueOf;
Condition0%0/3
$fillwidth && $fillwidth->valueOf
!ll&&!rl&&r
000
MC/DC0%0/2
$fillwidth && $fillwidth->valueOf
$fillwidth $fillwidth->valueOf
Truth table0%0/3
A && B
A= $fillwidthB= $fillwidth->valueOf
ABresult
0X0
100
111
488 0 my @lines = ();
489 0 my ($wd, $ht, $dp) = (0, 0, 0);
490 0 my ($minwd, $minht, $mindp) = (0, 0, 0);
491 0 ▶ my $vattach = $options{vattach} || 'baseline';
Condition0%0/2
$options{'vattach'} || 'baseline'
l!l
00
MC/DC0%0/1
$options{'vattach'} || 'baseline'
$options{'vattach'}
Truth table0%0/2
A
A= $options{'vattach'}
Aresult
11
00
492 5 ▶ no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
493 # Flatten top-level Lists (orrr pass-thru $fillwidth ???)
494 0 ▶ my @boxes = map { (ref $_ eq 'LaTeXML::Core::List' ? $_->unlist : $_); } @$boxes;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'LaTeXML::Core::List' ? : 0 0 0
495 0 foreach my $box (@boxes) {
496 0 ▶ next unless defined $box;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $box 0 0 0
497 0 ▶ next if ref $box && !$box->can('getSize'); # Care!! Since we're asking ALL args/compoments
Branch: 1 branch
BranchTrueFalseTotal
if ref $box and not $box->can("getSize") 0 0 0
Condition0%0/3
ref $box and not $box->can("getSize")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $box and not $box->can("getSize")
ref $box not $box->can("getSize")
Truth table0%0/3
A and not(B)
A= ref $boxB= not $box->can("getSize")
ABresult
0X0
100
111
498 ## Should any %options be inherited by the contained boxes?
499 0 ▶ my ($w, $h, $d) = (ref $box ? $box->getSize() : $font->computeStringSize($box));
Branch: 1 branch
BranchTrueFalseTotal
ref $box ? : 0 0 0
500 0 ▶ if (ref $w) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $w) { } 0 0 0
501 0 $wd += $w->valueOf; }
502 else {
503 0 Warn('expected', 'Dimension', undef,
504 "Width of " . Stringify($box) . " yielded a non-dimension: " . Stringify($w)); }
505 0 ▶ if (ref $h) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $h) { } 0 0 0
506 0 $ht = max($ht, $h->valueOf); }
507 else {
508 0 Warn('expected', 'Dimension', undef,
509 "Height of " . Stringify($box) . " yielded a non-dimension: " . Stringify($h)); }
510 0 ▶ if (ref $d) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $d) { } 0 0 0
511 0 $dp = max($dp, $d->valueOf); }
512 else {
513 0 Warn('expected', 'Dimension', undef,
514 "Depth of " . Stringify($box) . " yielded a non-dimension: " . Stringify($d)); }
515 0 ▶ if ((($options{layout} || '') eq 'vertical') # EVERY box is a row?
Branch: 2 branches
BranchTrueFalseTotal
if (($options{'layout'} || '') eq 'vertical' or ref $box and $box->getProperty('isBreak')) { } 0 0 0
elsif (defined $maxwidth and $wd >= $maxwidth) { } 0 0 0
Condition0%0/8
($options{"layout"} || "") eq "vertical" or ref $box and $box->getProperty("isBreak")
l!l&&r!l&&!r
000
$options{'layout'} || ''
l!l
00
ref $box and $box->getProperty("isBreak")
!ll&&!rl&&r
000
MC/DC0%0/3
($options{"layout"} || "") eq "vertical" or ref $box and $box->getProperty("isBreak")
$options{'layout'} ref $box $box->getProperty("isBreak")
Truth table0%0/4
A or B and C
A= $options{'layout'}B= ref $boxC= $box->getProperty("isBreak")
ABCresult
1XX1
0111
00X0
0100
516 || ((ref $box) && $box->getProperty('isBreak'))) { # || $box is a linebreak
517 0 push(@lines, [$wd, $ht, $dp]); $wd = $ht = $dp = 0; }
518 ▶ elsif ((defined $maxwidth) && ($wd >= $maxwidth)) { # or we've reached the requested width
Condition0%0/3
defined $maxwidth and $wd >= $maxwidth
!ll&&!rl&&r
000
MC/DC0%0/2
defined $maxwidth and $wd >= $maxwidth
defined $maxwidth $wd >= $maxwidth
Truth table0%0/3
A and B
A= defined $maxwidthB= $wd >= $maxwidth
ABresult
0X0
100
111
519 # Instead of a real linebreaking algorithm, just break off if too wide.
520 0 push(@lines, [$wd, $ht, $dp]); $wd = $ht = $dp = 0; }
521 }
522 0 ▶ if ($wd) { # be sure to get last line
Branch: 1 branch
BranchTrueFalseTotal
if ($wd) 0 0 0
523 0 push(@lines, [$wd, $ht, $dp]); }
524 # Deal with multiple lines
525 0 my $nlines = scalar(@lines);
526 0 ▶ if ($nlines == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nlines == 0) { } 0 0 0
527 0 $wd = $ht = $dp = 0; }
528 else {
529 0 $wd = max(map { $$_[0] } @lines);
530 0 $ht = sum(map { $$_[1] } @lines);
531 0 $dp = sum(map { $$_[2] } @lines);
532 0 ▶ if ($vattach eq 'top') { # Top of box is aligned with top(?) of current text
Branch: 3 branches
BranchTrueFalseTotal
if ($vattach eq 'top') { } 0 0 0
elsif ($vattach eq 'bottom') { } 0 0 0
elsif ($vattach eq 'middle') { } 0 0 0
533 0 my ($w, $h, $d) = $font->getNominalSize;
534 0 $h = $h->valueOf;
535 0 $dp = $ht + $dp - $h; $ht = $h; }
536 elsif ($vattach eq 'bottom') { # Bottom of box is aligned with bottom (?) of current text
537 0 $ht = $ht + $dp; $dp = 0; }
538 elsif ($vattach eq 'middle') {
539 0 my ($w, $h, $d) = $font->getNominalSize;
540 0 $h = $h->valueOf;
541 0 my $c = ($ht + $dp) / 2;
542 0 $ht = $c + $h / 2; $dp = $c - $h / 2; }
543 else { # default is baseline (of the 1st line)
544 0 my $h = $lines[0][1];
545 0 $dp = $ht + $dp - $h; $ht = $h; } }
546 0 $wd = max($minwd, $wd); $ht = max($minht, $ht); $dp = max($mindp, $dp);
547 #print "BOXES SIZE ".($wd/65536)." x ".($ht/65536)." + ".($dp/65336)." for "
548 # .join(' ',grep {$_} map { Stringify($_) } @$boxes)."\n";
549 0 Debug("Size boxes " . join(',', map { $_ . '=' . ToString($options{$_}); } sort keys %options) . "\n"
550 0 . " Boxes: " . join(',', map { '[[' . ToString($_) . ']]'; } @$boxes) . "\n"
551 0 . " Sizes: " . join("\n", map { _showsize(@$_); } @lines) . "\n"
552 0 ▶ . " => " . _showsize($wd, $ht, $dp)) if $LaTeXML::DEBUG{'size-detailed'};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"size-detailed"} 0 0 0
553 0 return (Dimension($wd), Dimension($ht), Dimension($dp)); }
554  
555 sub _showsize {
556 0 ▶ my ($wd, $ht, $dp) = @_;
Subroutine _showsize: not called CC=1 SCAR=6.9
557 0 return ($wd / 65536) . " x " . ($ht / 65536) . " + " . ($dp / 65336); }
558  
559 sub isSticky {
560 0 ▶ my ($self) = @_;
Subroutine isSticky: not called CC=2 SCAR=17.9
Pod undocumented
561 0 ▶ return $$self[0] && ($$self[0] =~ /^(?:serif|sansserif|typewriter)$/); }
Condition0%0/3
$self->[0] && $self->[0] =~ /^(?:serif|sansserif|typewriter)$/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[0] && $self->[0] =~ /^(?:serif|sansserif|typewriter)$/
$self->[0] $self->[0] =~ /^(?:serif|sansserif|typewriter)$/
Truth table0%0/3
A && B
A= $self->[0]B= $self->[0] =~ /^(?:serif|sansserif|typewriter)$/
ABresult
0X0
100
111
562  
563 5 our %scriptstylemap = (display => 'script', text => 'script',
564 script => 'scriptscript', scriptscript => 'scriptscript');
565 5 our %fracstylemap = (display => 'text', text => 'script',
566 script => 'scriptscript', scriptscript => 'scriptscript');
567 5 our %stylesize = (display => 10, text => 10,
568 script => 7, scriptscript => 5);
569  
570 # NOTE: In math, NORMALLY, setting any one of
571 # family, series or shape
572 # will, usually, automatically reset the others to thier defaults!
573 # You must arrange this in the calls....
574 sub merge {
575 0 ▶ my ($self, %options) = @_;
Subroutine merge: not called CC=36 SCAR=71.9
Pod undocumented
576 # Evaluate any functional values given.
577 0 foreach my $k (keys %options) {
578 0 ▶ $options{$k} = &{ $options{$k} }() if ref $options{$k} eq 'CODE'; }
Branch: 1 branch
BranchTrueFalseTotal
if ref $options{$k} eq "CODE" 0 0 0
579  
580 0 my $family = $options{family};
581 0 my $series = $options{series};
582 0 my $shape = $options{shape};
583 0 my $size = rationalizeFontSize($options{size});
584 0 my $color = $options{color};
585 0 my $bg = $options{background};
586 0 my $opacity = $options{opacity};
587 0 my $encoding = $options{encoding};
588 0 my $language = $options{language};
589 0 my $mathstyle = $options{mathstyle};
590  
591 0 ▶ if ($options{forcebold}) { # for compatibility
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"forcebold"}) 0 0 0
592 0 $series = 'bold'; $options{forceseries} = 1; }
593 my $flags = 0
594 | ($options{forcefamily} ? $FLAG_FORCE_FAMILY : 0)
595 | ($options{forceseries} ? $FLAG_FORCE_SERIES : 0)
596 0 ▶ | ($options{forceshape} ? $FLAG_FORCE_SHAPE : 0);
Branch: 3 branches
BranchTrueFalseTotal
$options{'forcefamily'} ? : 0 0 0
$options{'forceseries'} ? : 0 0 0
$options{'forceshape'} ? : 0 0 0
597  
598 0 my $oflags = $$self[10];
599 # Fallback to positional invocation:
600 0 ▶ $family = $$self[0] if (!defined $family) || ($oflags & $FLAG_FORCE_FAMILY);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $family or $oflags & $FLAG_FORCE_FAMILY 0 0 0
Condition0%0/3
not defined $family or $oflags & $FLAG_FORCE_FAMILY
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $family or $oflags & $FLAG_FORCE_FAMILY
not defined $family $oflags & $FLAG_FORCE_FAMILY
Truth table0%0/3
not(A) or B
A= not defined $familyB= $oflags & $FLAG_FORCE_FAMILY
ABresult
1X1
011
000
601 0 ▶ $series = $$self[1] if (!defined $series) || ($oflags & $FLAG_FORCE_SERIES);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $series or $oflags & $FLAG_FORCE_SERIES 0 0 0
Condition0%0/3
not defined $series or $oflags & $FLAG_FORCE_SERIES
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $series or $oflags & $FLAG_FORCE_SERIES
not defined $series $oflags & $FLAG_FORCE_SERIES
Truth table0%0/3
not(A) or B
A= not defined $seriesB= $oflags & $FLAG_FORCE_SERIES
ABresult
1X1
011
000
602 0 ▶ $shape = $$self[2] if (!defined $shape) || ($oflags & $FLAG_FORCE_SHAPE);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $shape or $oflags & $FLAG_FORCE_SHAPE 0 0 0
Condition0%0/3
not defined $shape or $oflags & $FLAG_FORCE_SHAPE
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $shape or $oflags & $FLAG_FORCE_SHAPE
not defined $shape $oflags & $FLAG_FORCE_SHAPE
Truth table0%0/3
not(A) or B
A= not defined $shapeB= $oflags & $FLAG_FORCE_SHAPE
ABresult
1X1
011
000
603 0 ▶ $size = $$self[3] if (!defined $size);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 0 0
604 0 ▶ $color = $$self[4] if (!defined $color);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $color 0 0 0
605 0 ▶ $bg = $$self[5] if (!defined $bg);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bg 0 0 0
606 0 ▶ $opacity = $$self[6] if (!defined $opacity);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opacity 0 0 0
607 0 ▶ $encoding = $$self[7] if (!defined $encoding);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $encoding 0 0 0
608 0 ▶ $language = $$self[8] if (!defined $language);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $language 0 0 0
609 0 ▶ $mathstyle = $$self[9] if (!defined $mathstyle);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mathstyle 0 0 0
610 0 ▶ $flags = ($$self[10] || 0) | $flags;
Condition0%0/2
$self->[10] || 0
l!l
00
MC/DC0%0/1
$self->[10] || 0
$self->[10]
Truth table0%0/2
A
A= $self->[10]
Aresult
11
00
611  
612 0 ▶ if (my $scale = $options{scale}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $scale = $options{"scale"}) 0 0 0
613 0 $size = $scale * $size; }
614 # Set the mathstyle, and also the size from the mathstyle
615 # But we may need to scale that size against the existing or requested size.
616 0 ▶ my $stylescale = ($$self[3] ? $$self[3] / $stylesize{ $$self[9] || 'display' } : 1);
Branch: 1 branch
BranchTrueFalseTotal
$self->[3] ? : 0 0 0
Condition0%0/2
$self->[9] || 'display'
l!l
00
MC/DC0%0/1
$self->[9] || 'display'
$self->[9]
Truth table0%0/2
A
A= $self->[9]
Aresult
11
00
617 0 ▶ if ($options{size}) { } # Explicitly requested size, use it
Branch: 4 branches
BranchTrueFalseTotal
if ($options{'size'}) { } 0 0 0
elsif ($options{'mathstyle'}) { } 0 0 0
elsif ($options{'scripted'}) { } 0 0 0
elsif ($options{'fraction'}) { } 0 0 0
618 elsif ($options{mathstyle}) { # otherwise set the size from mathstyle
619 0 $size = $stylescale * $stylesize{$mathstyle}; }
620 elsif ($options{scripted}) { # Or adjust both the mathstyle & size for scripts
621 0 ▶ $mathstyle = $scriptstylemap{ $mathstyle || 'display' };
Condition0%0/2
$mathstyle || 'display'
l!l
00
MC/DC0%0/1
$mathstyle || 'display'
$mathstyle
Truth table0%0/2
A
A= $mathstyle
Aresult
11
00
622 0 ▶ $size = $stylescale * $stylesize{ $mathstyle || 'display' }; }
Condition0%0/2
$mathstyle || 'display'
l!l
00
MC/DC0%0/1
$mathstyle || 'display'
$mathstyle
Truth table0%0/2
A
A= $mathstyle
Aresult
11
00
623 elsif ($options{fraction}) { # Or adjust both for fractions
624 0 ▶ $mathstyle = $fracstylemap{ $mathstyle || 'display' };
Condition0%0/2
$mathstyle || 'display'
l!l
00
MC/DC0%0/1
$mathstyle || 'display'
$mathstyle
Truth table0%0/2
A
A= $mathstyle
Aresult
11
00
625 0 ▶ $size = $stylescale * $stylesize{ $mathstyle || 'display' }; }
Condition0%0/2
$mathstyle || 'display'
l!l
00
MC/DC0%0/1
$mathstyle || 'display'
$mathstyle
Truth table0%0/2
A
A= $mathstyle
Aresult
11
00
626  
627 0 ▶ if ($options{emph}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"emph"}) 0 0 0
628 0 ▶ $shape = ($shape eq 'italic' ? 'upright' : 'italic');
Branch: 1 branch
BranchTrueFalseTotal
$shape eq 'italic' ? : 0 0 0
629 0 $flags |= $FLAG_EMPH; }
630 0 ▶ $flags &= ~$FLAG_EMPH if $mathstyle; # Disable emph in math
Branch: 1 branch
BranchTrueFalseTotal
if $mathstyle 0 0 0
631  
632 0 my $newfont = (ref $self)->new_internal($family, $series, $shape, $size,
633 $color, $bg, $opacity,
634 $encoding, $language,
635 $mathstyle, $flags);
636 0 ▶ if (my $specialize = $options{specialize}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $specialize = $options{"specialize"}) 0 0 0
637 0 $newfont = $newfont->specialize($specialize); }
638 0 return $newfont; }
639  
640 # Instanciate the font for a particular class of symbols.
641 # NOTE: This works in `normal' latex, but probably needs some tunability.
642 # Depending on the fonts being used, the allowable combinations may be different.
643 # Getting the font right is important, since the author probably
644 # thinks of the identity of the symbols according to what they SEE in the printed
645 # document. Even though the markup might seem to indicate something else...
646  
647 # Use Unicode properties to determine font merging.
648 sub specialize {
649 0 ▶ my ($self, $string) = @_;
Subroutine specialize: not called CC=30 SCAR=68.4
Pod documented
650 0 ▶ return $self if !(defined $string) || ref $string; # ?
Branch: 1 branch
BranchTrueFalseTotal
if not defined $string or ref $string 0 0 0
Condition0%0/3
not defined $string or ref $string
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $string or ref $string
not defined $string ref $string
Truth table0%0/3
not(A) or B
A= not defined $stringB= ref $string
ABresult
1X1
011
000
651 0 my ($family, $series, $shape, $size, $color, $bg, $opacity,
652 $encoding, $language, $mathstyle, $flags) = @$self;
653 0 ▶ my $deffamily = ($flags & $FLAG_FORCE_FAMILY ? $family || $DEFFAMILY : $DEFFAMILY);
Branch: 1 branch
BranchTrueFalseTotal
$flags & $FLAG_FORCE_FAMILY ? : 0 0 0
Condition0%0/3
$family or $DEFFAMILY
l!l&&r!l&&!r
000
MC/DC0%0/2
$family or $DEFFAMILY
$family $DEFFAMILY
Truth table0%0/3
A or B
A= $familyB= $DEFFAMILY
ABresult
1X1
011
000
654 0 ▶ my $defseries = ($flags & $FLAG_FORCE_SERIES ? $series || $DEFSERIES : $DEFSERIES);
Branch: 1 branch
BranchTrueFalseTotal
$flags & $FLAG_FORCE_SERIES ? : 0 0 0
Condition0%0/3
$series or $DEFSERIES
l!l&&r!l&&!r
000
MC/DC0%0/2
$series or $DEFSERIES
$series $DEFSERIES
Truth table0%0/3
A or B
A= $seriesB= $DEFSERIES
ABresult
1X1
011
000
655 0 ▶ my $defshape = ($flags & $FLAG_FORCE_SHAPE ? $shape || $DEFSHAPE : $DEFSHAPE);
Branch: 1 branch
BranchTrueFalseTotal
$flags & $FLAG_FORCE_SHAPE ? : 0 0 0
Condition0%0/3
$shape or $DEFSHAPE
l!l&&r!l&&!r
000
MC/DC0%0/2
$shape or $DEFSHAPE
$shape $DEFSHAPE
Truth table0%0/3
A or B
A= $shapeB= $DEFSHAPE
ABresult
1X1
011
000
656 0 ▶ if (($string =~ /^\p{Latin}$/) && ($string =~ /^\p{L}$/)) { # Latin Letter
Branch: 3 branches
BranchTrueFalseTotal
if ($string =~ /^\p{Latin}$/ and $string =~ /^\p{L}$/) { } 0 0 0
elsif ($string =~ /^\p{Greek}$/) { } 0 0 0
elsif ($string =~ /^\p{N}$/) { } 0 0 0
Condition0%0/3
$string =~ /^\p{Latin}$/ and $string =~ /^\p{L}$/
!ll&&!rl&&r
000
MC/DC0%0/2
$string =~ /^\p{Latin}$/ and $string =~ /^\p{L}$/
$string =~ /^\p{Latin}$/ $string =~ /^\p{L}$/
Truth table0%0/3
A and B
A= $string =~ /^\p{Latin}$/B= $string =~ /^\p{L}$/
ABresult
0X0
100
111
657 0 ▶ $shape = 'italic' if !$shape && !$family; }
Branch: 1 branch
BranchTrueFalseTotal
unless $shape or $family 0 0 0
Condition0%0/3
$shape or $family
l!l&&r!l&&!r
000
MC/DC0%0/2
$shape or $family
$shape $family
Truth table0%0/3
A or B
A= $shapeB= $family
ABresult
1X1
011
000
658 elsif ($string =~ /^\p{Greek}$/) { # Single Greek character?
659 0 ▶ if ($string =~ /^\p{Lu}$/) { # Uppercase
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /^\p{Lu}$/) { } 0 0 0
660 0 ▶ if (!$family || ($family eq 'math')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $family or $family eq "math") 0 0 0
Condition0%0/3
not $family or $family eq "math"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $family or $family eq "math"
not $family $family eq "math"
Truth table0%0/3
not(A) or B
A= not $familyB= $family eq "math"
ABresult
1X1
011
000
661 0 $family = $deffamily;
662 0 ▶ $shape = $defshape if $shape && ($shape ne $DEFSHAPE); } } # if ANY shape, must be default
Branch: 1 branch
BranchTrueFalseTotal
if $shape and $shape ne $DEFSHAPE 0 0 0
Condition0%0/3
$shape and $shape ne $DEFSHAPE
!ll&&!rl&&r
000
MC/DC0%0/2
$shape and $shape ne $DEFSHAPE
$shape $shape ne $DEFSHAPE
Truth table0%0/3
A and B
A= $shapeB= $shape ne $DEFSHAPE
ABresult
0X0
100
111
663 else { # Lowercase
664 0 ▶ $family = $deffamily if !$family || ($family ne $DEFFAMILY);
Branch: 1 branch
BranchTrueFalseTotal
if not $family or $family ne $DEFFAMILY 0 0 0
Condition0%0/3
not $family or $family ne $DEFFAMILY
l!l&&r!l&&!r
000
MC/DC0%0/2
not $family or $family ne $DEFFAMILY
not $family $family ne $DEFFAMILY
Truth table0%0/3
not(A) or B
A= not $familyB= $family ne $DEFFAMILY
ABresult
1X1
011
000
665 0 ▶ $shape = 'italic' if !$shape || !($flags & $FLAG_FORCE_SHAPE); # always ?
Branch: 1 branch
BranchTrueFalseTotal
unless $shape and $flags & $FLAG_FORCE_SHAPE 0 0 0
Condition0%0/3
$shape and $flags & $FLAG_FORCE_SHAPE
!ll&&!rl&&r
000
MC/DC0%0/2
$shape and $flags & $FLAG_FORCE_SHAPE
$shape $flags & $FLAG_FORCE_SHAPE
Truth table0%0/3
A and B
A= $shapeB= $flags & $FLAG_FORCE_SHAPE
ABresult
0X0
100
111
666 0 ▶ if ($series && ($series ne $DEFSERIES)) { $series = $defseries; }
Branch: 1 branch
BranchTrueFalseTotal
if ($series and $series ne $DEFSERIES) 0 0 0
Condition0%0/3
$series and $series ne $DEFSERIES
!ll&&!rl&&r
000
MC/DC0%0/2
$series and $series ne $DEFSERIES
$series $series ne $DEFSERIES
Truth table0%0/3
A and B
A= $seriesB= $series ne $DEFSERIES
ABresult
0X0
100
111
667 } }
668 elsif ($string =~ /^\p{N}$/) { # Digit
669 0 ▶ if (!$family || ($family eq 'math')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $family or $family eq "math") 0 0 0
Condition0%0/3
not $family or $family eq "math"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $family or $family eq "math"
not $family $family eq "math"
Truth table0%0/3
not(A) or B
A= not $familyB= $family eq "math"
ABresult
1X1
011
000
670 0 $family = $deffamily;
671 0 $shape = $defshape; } } # defaults, always.
672 else { # Other Symbol
673 0 $family = $deffamily;
674 0 $shape = $defshape; # defaults, always.
675 0 ▶ if ($series && ($series ne $DEFSERIES)) { $series = $defseries; } }
Branch: 1 branch
BranchTrueFalseTotal
if ($series and $series ne $DEFSERIES) 0 0 0
Condition0%0/3
$series and $series ne $DEFSERIES
!ll&&!rl&&r
000
MC/DC0%0/2
$series and $series ne $DEFSERIES
$series $series ne $DEFSERIES
Truth table0%0/3
A and B
A= $seriesB= $series ne $DEFSERIES
ABresult
0X0
100
111
676 0 return (ref $self)->new_internal($family, $series, $shape, $size,
677 $color, $bg, $opacity,
678 $encoding, $language, $mathstyle, $flags); }
679  
680 # A special form of merge when copying/moving nodes to a new context,
681 # particularly math which become scripts or such.
682 5 our %mathstylestep = (
683 display => { display => 0, text => 1, script => 2, scriptscript => 3 },
684 text => { display => -1, text => 0, script => 1, scriptscript => 2 },
685 script => { display => -2, text => -1, script => 0, scriptscript => 1 },
686 scriptscript => { display => -3, text => -2, script => -1, scriptscript => 0 });
687 5 our %stepmathstyle = (
688 display => { -3 => 'display', -2 => 'display', -1 => 'display',
689 0 => 'display', 1 => 'text', 2 => 'script', 3 => 'scriptscript' },
690 text => { -3 => 'display', -2 => 'display', -1 => 'display',
691 0 => 'text', 1 => 'script', 2 => 'scriptscript', 3 => 'scriptscript' },
692 script => { -3 => 'display', -2 => 'display', -1 => 'text',
693 0 => 'script', 1 => 'scriptscript', 2 => 'scriptscript', 3 => 'scriptscript' },
694 scriptscript => { -3 => 'display', -2 => 'text', -1 => 'script',
695 0 => 'scriptscript', 1 => 'scriptscript', 2 => 'scriptscript', 3 => 'scriptscript' });
696  
697 sub purestyleChanges {
698 0 ▶ my ($self, $other) = @_;
Subroutine purestyleChanges: not called CC=4 SCAR=30.0
Pod undocumented
699 0 my $mathstyle = $self->getMathstyle;
700 0 my $othermathstyle = $other->getMathstyle;
701 0 my $othercolor = $other->getColor;
702 return (
703 scale => $other->getSize / $self->getSize,
704 (isDiff($othercolor, $DEFCOLOR) ? (color => $othercolor) : ()),
705 background => $other->getBackground,
706 opacity => $other->getOpacity, # should multiply or replace?
707 ($mathstyle && $othermathstyle
708 0 ▶ ? (mathstylestep => $mathstylestep{$mathstyle}{$othermathstyle})
Branch: 2 branches
BranchTrueFalseTotal
isDiff($othercolor, $DEFCOLOR) ? : 0 0 0
$mathstyle && $othermathstyle ? : 0 0 0
Condition0%0/3
$mathstyle and $othermathstyle
!ll&&!rl&&r
000
MC/DC0%0/2
$mathstyle and $othermathstyle
$mathstyle $othermathstyle
Truth table0%0/3
A and B
A= $mathstyleB= $othermathstyle
ABresult
0X0
100
111
709 : ()),
710 ); }
711  
712 sub mergePurestyle {
713 0 ▶ my ($self, %stylechanges) = @_;
Subroutine mergePurestyle: not called CC=6 SCAR=37.4
Pod undocumented
714 0 my $new = $self->new_internal(@$self);
715 0 ▶ $$new[3] = $$self[3] * $stylechanges{scale} if $stylechanges{scale};
Branch: 1 branch
BranchTrueFalseTotal
if $stylechanges{"scale"} 0 0 0
716 0 ▶ $$new[4] = $stylechanges{color} if $stylechanges{color};
Branch: 1 branch
BranchTrueFalseTotal
if $stylechanges{"color"} 0 0 0
717 0 ▶ $$new[5] = $stylechanges{background} if $stylechanges{background};
Branch: 1 branch
BranchTrueFalseTotal
if $stylechanges{"background"} 0 0 0
718 0 ▶ $$new[6] = $stylechanges{opacity} if $stylechanges{opacity};
Branch: 1 branch
BranchTrueFalseTotal
if $stylechanges{"opacity"} 0 0 0
719 0 ▶ $$new[9] = $stepmathstyle{ $$self[9] }{ $stylechanges{mathstylestep} } if $stylechanges{mathstylestep};
Branch: 1 branch
BranchTrueFalseTotal
if $stylechanges{"mathstylestep"} 0 0 0
720 0 return new; }
721  
722 #**********************************************************************
723 5 1;
724  
725 __END__
« lib/LaTeXML/Util/Pack.pm ↑ Summary lib/LaTeXML/Core/Mouth.pm »