Skip to content

Commit

Permalink
Added minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszkrzaczkowski committed Mar 22, 2022
1 parent d0391c3 commit 1a872b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions lib/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public static function add(string ...$numbers)
foreach ($numbers as $number) {
$result = bcadd($result, $number, static::$scale);
}

return $result;
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Style/NumericValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 7 additions & 3 deletions lib/Style/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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]);
}
Expand Down

0 comments on commit 1a872b8

Please sign in to comment.