1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of PhpAidc LabelPrinter package. |
5
|
|
|
* |
6
|
|
|
* © Appwilio (https://appwilio.com) |
7
|
|
|
* © JhaoDa (https://github.com/jhaoda) |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace PhpAidc\LabelPrinter\Language\Fingerprint; |
16
|
|
|
|
17
|
|
|
use PhpAidc\LabelPrinter\Command\Bitmap; |
18
|
|
|
use PhpAidc\LabelPrinter\Command\TextLine; |
19
|
|
|
use PhpAidc\LabelPrinter\Emulation\EmulateText; |
20
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Font; |
21
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Align; |
22
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Invert; |
23
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Rotate; |
24
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Magnify; |
25
|
|
|
use PhpAidc\LabelPrinter\Language\Fingerprint\Concerns\Position; |
26
|
|
|
|
27
|
|
|
final class FingerprintTextLine |
28
|
|
|
{ |
29
|
|
|
use Font; |
30
|
|
|
use Align; |
31
|
|
|
use Invert; |
32
|
|
|
use Rotate; |
33
|
|
|
use Magnify; |
34
|
|
|
use Position; |
35
|
|
|
use EmulateText; |
36
|
|
|
|
37
|
|
|
public function translate(TextLine $command): iterable |
38
|
|
|
{ |
39
|
|
|
if ($command->shouldEmulate()) { |
40
|
|
|
$image = $this->emulate($command, $command->getMaxWidth()); |
41
|
|
|
|
42
|
|
|
yield from (new FingerprintBitmap())->translate( |
43
|
|
|
new Bitmap($command->getX(), $command->getY(), $image) |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
return; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
yield from $this->position($command); |
50
|
|
|
|
51
|
|
|
yield from $this->rotate($command); |
52
|
|
|
|
53
|
|
|
yield from $this->invert($command); |
54
|
|
|
|
55
|
|
|
yield from $this->align($command); |
56
|
|
|
|
57
|
|
|
yield from $this->font($command); |
58
|
|
|
|
59
|
|
|
yield \sprintf('PT "%s"', $command->getText()); |
60
|
|
|
|
61
|
|
|
// reset |
62
|
|
|
yield from $this->resetAlign($command); |
63
|
|
|
yield from $this->resetInvert($command); |
64
|
|
|
yield from $this->resetRotate($command); |
65
|
|
|
yield from $this->resetMagnify($command); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|