Skip to content

Commit

Permalink
Added width in setFont method (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: Anderson Luiz Silvério <[email protected]>
  • Loading branch information
imvz and andersonls authored May 26, 2023
1 parent 0b951ea commit eb8403c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ZplBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,22 @@ public function __construct(string $unit = 'dots', int $resolution = 203)
* {@inheritDoc}
* @see \Zpl\AbstractBuilder::setFont()
*/
public function setFont(string $font, float $size) : void
public function setFont(string $font, float $size, ?float $width = null) : void
{
$fontMapper = $this->fontMapper;
$mapper = $fontMapper::$mapper;
if (isset($mapper[$font])) {
$font = $mapper[$font];
}
$size = $size * ($this->resolution * 0.014);
$this->commands[] = '^CF' . $font . ',' . $size;
$command = '^CF' . $font . ',' . $size;

if ($width !== null) {
$width = $width * ($this->resolution * 0.014);
$command .= ',' . $width;
}

$this->commands[] = $command;
}

/**
Expand Down

0 comments on commit eb8403c

Please sign in to comment.