From 1a872b8d951a4c4b8d27d9a0449820d84c87558a Mon Sep 17 00:00:00 2001 From: Mariusz Krzaczkowski Date: Tue, 22 Mar 2022 11:32:25 +0100 Subject: [PATCH] Added minor improvements --- lib/Math.php | 2 -- lib/Style/NumericValue.php | 2 +- lib/Style/Style.php | 10 +++++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Math.php b/lib/Math.php index 667d116..957b99d 100644 --- a/lib/Math.php +++ b/lib/Math.php @@ -71,7 +71,6 @@ public static function add(string ...$numbers) foreach ($numbers as $number) { $result = bcadd($result, $number, static::$scale); } - return $result; } @@ -172,7 +171,6 @@ public static function max(string ...$numbers) foreach ($numbers as $number) { $result = 1 === bccomp($number, $result, static::$scale) ? $number : $result; } - return $result; } diff --git a/lib/Style/NumericValue.php b/lib/Style/NumericValue.php index 470a776..51e1067 100644 --- a/lib/Style/NumericValue.php +++ b/lib/Style/NumericValue.php @@ -60,7 +60,7 @@ public function init(string $value, bool $isFont = false) { $this->original = $value; $this->value = \YetiForcePDF\Style\Normalizer\Normalizer::getNumericValue($value); - $this->unit = \YetiForcePDF\Style\Normalizer\Normalizer::getNumericUnit($value); + $this->unit = \YetiForcePDF\Style\Normalizer\Normalizer::getNumericUnit($value, 'px'); $this->isFont = $isFont; return $this; } diff --git a/lib/Style/Style.php b/lib/Style/Style.php index a408e63..19735ad 100644 --- a/lib/Style/Style.php +++ b/lib/Style/Style.php @@ -1096,7 +1096,11 @@ public function getMaxLineHeight() } $box = $this->getBox(); $lineHeight = $this->getRules('line-height'); - if ('inline' !== !$this->getRules('display')) { + if (false !== strpos($lineHeight, '%')) { + // TODO: Add percentage support + $lineHeight = '0.00'; + } + if ('inline' !== $this->getRules('display') && '0.00' !== $this->getVerticalPaddingsWidth() && '0.00' !== $this->getVerticalBordersWidth()) { $lineHeight = Math::add($lineHeight, $this->getVerticalPaddingsWidth(), $this->getVerticalBordersWidth()); } foreach ($box->getChildren() as $child) { @@ -1154,7 +1158,7 @@ public function parseInline() $rulesParsed = []; foreach ($rules as $rule) { $rule = trim($rule); - if ('' !== $rule) { + if ('' !== $rule && false !== strpos($rule, ':')) { $ruleExploded = explode(':', $rule); $ruleName = trim($ruleExploded[0]); $ruleValue = trim($ruleExploded[1]); @@ -1423,7 +1427,7 @@ protected function parse() $inline = []; foreach ($inlineTemp as $rule) { $rule = trim($rule); - if ('' !== $rule) { + if ('' !== $rule && false !== strpos($rule, ':')) { $ruleExploded = explode(':', $rule); $inline[trim($ruleExploded[0])] = trim($ruleExploded[1]); }