Skip to content

Commit

Permalink
Add support for 'pt' unit (12pt = 16px)
Browse files Browse the repository at this point in the history
  • Loading branch information
meyfa committed Nov 12, 2016
1 parent 35ab405 commit a02b4c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/SVG.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class SVG
public static function convertUnit($unit, $viewLength)
{
$matches = array();
$match = preg_match('/^([+-]?\d*\.?\d*)(px|%)?$/', $unit, $matches);
$match = preg_match('/^([+-]?\d*\.?\d*)(px|pt|%)?$/', $unit, $matches);

if (!$match) {
return false;
Expand All @@ -40,6 +40,9 @@ public static function convertUnit($unit, $viewLength)

if ($unit === 'px' || $unit === null) {
return $num;
} elseif ($unit === 'pt') {
// 12pt == 16px, so ratio = 12/16 = 0.75
return $num / 0.75;
} elseif ($unit === '%') {
return ($num / 100) * $viewLength;
}
Expand Down

0 comments on commit a02b4c1

Please sign in to comment.