| 1 | # /=====================================================================\ # | ||||||||||||
| 2 | # | LaTeXML::Core::MuDimension | # | ||||||||||||
| 3 | # | Representation of Math Dimensions | # | ||||||||||||
| 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::Core::MuDimension; | ||||||||||||
| 13 | 5 | ▶ | use LaTeXML::Global; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 5 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 5 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 5 | ▶ | use LaTeXML::Common::Number; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 5 | ▶ | use LaTeXML::Common::Dimension; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 5 | ▶ | use base qw(LaTeXML::Common::Dimension); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 5 | ▶ | use base qw(Exporter); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 5 | our @EXPORT = (qw(&MuDimension)); | |||||||||||
| 21 | |||||||||||||
| 22 | #====================================================================== | ||||||||||||
| 23 | # Exported constructor. | ||||||||||||
| 24 | # Note that MuDimension is almost never used in TeX (there's no \newmudimen) | ||||||||||||
| 25 | |||||||||||||
| 26 | # Create a MuDimension given either a float with "mu" OR a number in scaled mu (NOT scaled points!) | ||||||||||||
| 27 | 0 | ▶ | sub MuDimension { | ||||||||||
|
Subroutine
MuDimension: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 28 | 0 | my ($spec) = @_; | |||||||||||
| 29 | 0 | return LaTeXML::Core::MuDimension->new($spec); } | |||||||||||
| 30 | |||||||||||||
| 31 | 0 | ▶ | sub _unit { return 'mu'; } | ||||||||||
|
Subroutine
_unit: not called CC=1 SCAR=6.9
| |||||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||
| 34 | 0 | my ($class, $spec) = @_; | |||||||||||
| 35 | 0 | ▶ | $spec = "0" unless $spec; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | 0 | ▶ | $spec = ToString($spec) if ref $spec; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | 0 | ▶ | if ($spec =~ /^(-?\d*\.?\d*)mu$/) { # mu given, convert to scaled mu | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | 0 | return bless [fixpoint($1, $UNITY)], $class; } # fake "mu" in sp | |||||||||||
| 39 | else { | ||||||||||||
| 40 | # See comment in Dimension for why kround rather than int | ||||||||||||
| 41 | 0 | ▶ | return bless [kround($spec || 0)], $class; } } | ||||||||||
|
Condition0%0/2
$spec || 0
MC/DC0%0/1
$spec || 0
$spec
Truth table0%0/2
A
A= $spec
| |||||||||||||
| 42 | |||||||||||||
| 43 | #====================================================================== | ||||||||||||
| 44 | 0 | ▶ | sub stringify { | ||||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 45 | 0 | my ($self) = @_; | |||||||||||
| 46 | 0 | return "MuDimension[" . $$self[0] . "]"; } | |||||||||||
| 47 | |||||||||||||
| 48 | # Note that $mu->valueOf will return scaled mu, NOT scaled pts; | ||||||||||||
| 49 | # But in priniple these should never be combined with regular Dimensions/Glue | ||||||||||||
| 50 | # TeX gives error "Incompatible glue units" | ||||||||||||
| 51 | # HOWEVER, since we'll encounter mixtures of mu & pts when computing sizes, | ||||||||||||
| 52 | # we're going to have to make sure we use the right scaling! | ||||||||||||
| 53 | 0 | ▶ | sub spValue { | ||||||||||
|
Subroutine
spValue: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 54 | 0 | my ($self, $prec) = @_; | |||||||||||
| 55 | 0 | return kround($$self[0] * $STATE->lookupValue('font')->getMUWidth / $UNITY); } | |||||||||||
| 56 | |||||||||||||
| 57 | # A mu is 1/18th of an em in the current math font. | ||||||||||||
| 58 | # 1 mu = 1em/18 = 10pt/18 = 5/9 pt; 1pt = 9/5mu = 1.8mu (for 10pt) | ||||||||||||
| 59 | 0 | ▶ | sub ptValue { | ||||||||||
|
Subroutine
ptValue: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 60 | 0 | my ($self, $prec) = @_; | |||||||||||
| 61 | 0 | return roundto($$self[0] / $UNITY / 1.8, $prec); } | |||||||||||
| 62 | |||||||||||||
| 63 | 0 | ▶ | sub pxValue { | ||||||||||
|
Subroutine
pxValue: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 64 | 0 | my ($self, $prec) = @_; | |||||||||||
| 65 | 0 | ▶ | return roundto($$self[0] / $UNITY / 1.8 * ($STATE->lookupValue('DPI') || 100 / 72.27), $prec); } | ||||||||||
|
Condition0%0/2
$LaTeXML::Core::MuDimension::STATE->lookupValue('DPI') || 1.3837000138370001423
MC/DC0%0/1
$LaTeXML::Core::MuDimension::STATE->lookupValue('DPI') || 1.3837000138370001423
$LaTeXML::Core::MuDimension::STATE->lookupValue('DPI')
Truth table0%0/2
A
A= $LaTeXML::Core::MuDimension::STATE->lookupValue('DPI')
| |||||||||||||
| 66 | |||||||||||||
| 67 | #====================================================================== | ||||||||||||
| 68 | 5 | 1; | |||||||||||
| 69 | |||||||||||||
| 70 | __END__ | ||||||||||||