Skip to content

Commit

Permalink
Fix additional whitespace calculation from SVG
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Apr 29, 2017
1 parent 2c5b527 commit 57ff855
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Writer/SvgWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ protected function addMargin($string)
$xml->rect['width'] = $targetSize;
$xml->rect['height'] = $targetSize;

$additionalWhitespace = (int) $xml->use['x'];
$additionalWhitespace = $targetSize;
foreach ($xml->use as $block) {
$additionalWhitespace = min($additionalWhitespace, (int) $block['x']);
}

$sourceBlockSize = (int) $xml->defs->rect['width'];
$blockCount = ($this->qrCode->getSize() - 2 * $additionalWhitespace) / $sourceBlockSize;
$targetBlockSize = $this->qrCode->getSize() / $blockCount;
Expand Down

0 comments on commit 57ff855

Please sign in to comment.