If you print to a thermal receipt printer which support the ESC/POS protocol, then you can format the receipts to make larger or smaller text.
If this is your first time reading about ESC/POS, have a read of What is ESC/POS, and how do I use it?. Some of these text size examples are borrowed from there, while some are new for this blog post.
Smaller text
Change height & width
Change width only (height=4)
Change height only (width=4)
Very narrow font
Very wide font
Largest possible font
Double-height and doule-width
There are also commands which specifically double the width and height. These overlap with the commands covered here, but you can find them in the escpos-php documentation.
Full example
These examples were authored for escpos-php, a PHP printer driver for thermal receipt printers. The full file ships as an example with the driver, and outputs a block of ESC/POS code which can be sent a printer to give the below output.
Receipt

PHP code
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
|
<?php
/**
* This print-out shows how large the available font sizes are. It is included
* separately due to the amount of text it prints.
*/
require __DIR__ . '/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
}
|
If text size is not what you’re after, then you can find similar examples in other posts I’ve tagged escpos.