ZPL how-to
Font size in ZPL
ZPL sizes text in dots, not points, and a font set with ^CF stays set for every field after it.
In plain ZPL
^XA
^FO40,40^A0N,80,80^FDBin A-12^FS
^FO40,160^A0N,34,34^FDShelf 3, left^FS
^XZ^A0N,80,80: font 0, normal orientation, 80 dots high and 80 wide. It applies to the next field only. Font 0 scales to any size; give it the same width as height for its normal shape, or a smaller width to narrow it.^CF0,40sets the default font for every field that follows, until the next^CF. A field with no^Aof its own takes whatever the last^CFset, which is easy to miss when you move a field.
Points to dots
Dots = points × dpi ÷ 72. A dot is 1/203 inch on a 203 dpi printer and 1/300 inch on a 300 dpi one, so the same ZPL prints smaller on a 300 dpi printer.
| Points | Dots at 203 dpi | Dots at 300 dpi |
|---|---|---|
| 8 | 23 | 33 |
| 10 | 28 | 42 |
| 12 | 34 | 50 |
| 18 | 51 | 75 |
| 24 | 68 | 100 |
The same label with zeepler
Send this body to POST https://api.zeepler.com/v1/zeeplify with your API key in the x-api-key header. It is a working request, not an illustration: on every change, our tests run this same file through the API's code and compare the result with the ZPL below.
1{2 "config": {3 "size": "4x2"4 },5 "data": {6 "title": "Bin A-12",7 "detail": "Shelf 3, left",8 "note": "Same size as the line above"9 },10 "templates": [11 {12 "type": "Text",13 "dataPath": "title",14 "coords": [40, 40],15 "font": "0,80"16 },17 {18 "type": "Text",19 "dataPath": "detail",20 "coords": [40, 160],21 "font": "0,34"22 },23 {24 "type": "Text",25 "dataPath": "note",26 "coords": [40, 220]27 }28 ]29}And the ZPL that comes back, ready to send to the printer:
^XA^MCY^XZ
^XA
^SZ2
^MMT
^MNY
^LL406
^PW812
^LH0,0
^CF0,80^FO40,40^FDBin A-12^FS
^CF0,34^FO40,160^FDShelf 3, left^FS
^FO40,220^FDSame size as the line above^FS
^XZfont becomes a ^CF before the field, so it carries over the same way: the third line has no font and prints at 34 dots, like the line above it. Give every Text element a font if you want each one to stay the size you chose when you reorder them.
Sending it
- Call the API from your own server or integration engine, not from a web page. An API key in a browser is a key anyone can copy.
- A successful call answers
200with the ZPL as plain text. A request the API cannot turn into a label answers400with every problem listed by field, and is not billed. - Send the ZPL to a Zebra or other ZPL printer at 203 dpi. At 300 dpi the same label prints at two-thirds of the size.
The API reference has every field and status code.
Before you go live
- Text does not wrap. A value longer than the space you left runs off the edge of the label, so set
maxLengthon any field whose length you do not control. - Coordinates are in dots from the top-left corner. Print one label, measure it, and adjust: there is no preview.
- Scan every barcode and QR code on a printed label before relying on it.
Related guides
- QR code size in ZPL: How ^BQ magnification sets the size of a QR code, and how to work out the size in dots.
- Printing ^, ~ and _ in ZPL: Why a caret or tilde in your data cuts the field short, and how ^FH prints them.
- Send ZPL to a Zebra printer from C#: Send ZPL from .NET to a network printer on port 9100, or to a USB printer through the Windows spooler, without the driver redrawing it.
Help with an integration
Email info@zeepler.com. You will get a reply within 2 business days. The support policy covers response times and version changes.