-
Notifications
You must be signed in to change notification settings - Fork 871
/
Copy pathtext-size.php
65 lines (55 loc) · 1.68 KB
/
text-size.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* This print-out shows how large the available font sizes are. It is included
* separately due to the amount of text it prints.
*
* @author Michael Billington <michael.billington@gmail.com>
*/
require __DIR__ . '/../vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
/* Initialize */
$printer -> initialize();
/* Text of various (in-proportion) sizes */
title($printer, "Change height & width\n");
for ($i = 1; $i <= 8; $i++) {
$printer -> setTextSize($i, $i);
$printer -> text($i);
}
$printer -> text("\n");
/* Width changing only */
title($printer, "Change width only (height=4):\n");
for ($i = 1; $i <= 8; $i++) {
$printer -> setTextSize($i, 4);
$printer -> text($i);
}
$printer -> text("\n");
/* Height changing only */
title($printer, "Change height only (width=4):\n");
for ($i = 1; $i <= 8; $i++) {
$printer -> setTextSize(4, $i);
$printer -> text($i);
}
$printer -> text("\n");
/* Very narrow text */
title($printer, "Very narrow text:\n");
$printer -> setTextSize(1, 8);
$printer -> text("The quick brown fox jumps over the lazy dog.\n");
/* Very flat text */
title($printer, "Very wide text:\n");
$printer -> setTextSize(4, 1);
$printer -> text("Hello world!\n");
/* Very large text */
title($printer, "Largest possible text:\n");
$printer -> setTextSize(8, 8);
$printer -> text("Hello\nworld!\n");
$printer -> cut();
$printer -> close();
function title(Printer $printer, $text)
{
$printer -> selectPrintMode(Printer::MODE_EMPHASIZED);
$printer -> text("\n" . $text);
$printer -> selectPrintMode(); // Reset
}