Skip to content

Commit

Permalink
Add line styles, italic mode and underline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubboucek committed May 12, 2020
1 parent f2f63c6 commit 5137e7a
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/Receipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ public function code128(string $data, int $width = 3, int $height = 42, int $tex
return $this;
}

public function line(): self
public function line(int $type = 0): self
{
// \xc4 = Em dash
$chars = [
// \xc4 = Em dash
0 => "\xc4",
1 => "-",
2 => "- ",
];
// 48 = chars to receipt width
return $this->writeLf(str_repeat("\xc4", 48), true);
return $this->writeLf(str_repeat($chars[$type], $type == 2 ? (48 / 2) : 48), true);
}

public function left(): self
Expand Down Expand Up @@ -169,6 +174,30 @@ public function unbold(): self
return $this;
}

public function italic(): self
{
$this->buff(self::C_ESC . "\x34\x01");
return $this;
}

public function unitalic(): self
{
$this->buff(self::C_ESC . "\x34\x00");
return $this;
}

public function underline(): self
{
$this->buff(self::C_ESC . "\x2d\x01");
return $this;
}

public function ununderline(): self
{
$this->buff(self::C_ESC . "\x2d\x00");
return $this;
}

public function fontA(): self
{
$this->buff(self::C_ESC . "\x4d\x00");
Expand Down

0 comments on commit 5137e7a

Please sign in to comment.