ZPL Commands

ZPL Fonts and Text: ^A, ^CF, ^FB and Field Blocks

Choose and size fonts, set defaults, and wrap and align text with field blocks so labels look tidy at any data length.

By ZPL Viewer Editorial Team4 min read

Key points

  • Font 0 is scalable; fonts A to H are bitmap fonts that scale in whole multiples.
  • ^A sets the font for one field; ^CF sets the default for the rest of the label.
  • ^FB wraps text in a fixed width, limits the number of lines and aligns left, centre, right or justified.
  • Inside a field block, \& starts a new line.

Text is the part of a label people read, so it deserves care. ZPL gives you a handful of commands for fonts, sizes and wrapping. Used well, they keep labels readable whether a product name is five characters or fifty.

Choosing a font with ^A

^Afo,h,w sets the font for the next field: font name f, orientation o (N, R, I or B), height h and width w in dots. Notice there is no comma between the font and orientation: ^A0N,40,40.

  • Font 0 is a smooth scalable font, a bold condensed sans serif. It is the most common choice and can be any size. Setting a width smaller than the height condenses it; a larger width stretches it.
  • Fonts A to H are bitmap fonts with fixed base sizes. Font A is 9 dots tall, font D 18 and font G 60, for example. When you ask for another size, the printer multiplies the base size by a whole number, so ^ADN,40,20 gives you font D at double size.
  • Downloaded fonts such as TrueType files can be stored in printer memory and called with ^A@. Viewers cannot see fonts stored only in the printer, so they substitute.

Setting a default with ^CF

^CFf,h,w sets the font used by every following field that has no ^A of its own. Put ^CF0,30 at the top of the label and you only need ^A where a field differs. This keeps code short and consistent.

Wrapping and aligning text with ^FB

^FBw,l,s,j,h turns a field into a block of text:

  • w: block width in dots. Text wraps at spaces to fit.
  • l: maximum number of lines (default 1). Extra text is printed over the last line, so set this high enough.
  • s: extra space between lines in dots, which can be negative.
  • j: justification: L, C, R or J (justified).
  • h: hanging indent for lines after the first.

Inside the data, the two characters \& force a new line. Centring a one line title is a common trick: ^FB812,1,0,C with ^FO0,y centres text across a 4 inch label.

Font and field block samples
^XA
^PW812
^LL609
^CF0,30
^FO40,30^A0N,60,60^FDFont 0 at 60 x 60^FS
^FO40,100^A0N,60,30^FDFont 0 at 60 x 30^FS
^FO40,170^ADN,36,20^FDBitmap font D^FS
^FO40,220^AAN,18,10^FDBitmap font A, small and narrow^FS
^FO40,270^GB730,3,3^FS
^FO40,290^FB730,3,6,C^A0N,34,30^FDA field block wraps long text across up to three lines and centres each line.^FS
^FO40,430^FB730,2,0,R^A0N,30,28^FDRight aligned\&second line^FS
^XZ

Text blocks with ^TB

^TBo,w,h is a newer alternative that wraps text inside a box of fixed width and height. Text that does not fit is cut off rather than overprinted, which can be safer for variable data. Not every older printer supports it.

Readability rules of thumb

  • Keep body text at least 20 dots high at 203 dpi (about 2.5 mm). Addresses usually look good at 30 to 45 dots.
  • Use reverse printing (^FR on a filled box) for headings instead of ever larger fonts.
  • Avoid squeezing font 0 below about 70 percent width; letters start to merge on thermal paper.
  • Allow for variable data: preview the longest realistic value, not only the sample.

How the preview handles fonts

Our ZPL Viewer uses a condensed font very close to font 0 and monospace substitutes for the bitmap fonts, sized to their exact cell dimensions. Heights and positions match the printer; long lines can differ by a few dots in width because Zebra's fonts are licensed. If text must fit an exact box, use a field block and leave a small margin. Rotated text is covered in rotation and orientation.

Preview this in the ZPL Viewer

Paste your code, pick the label size and density, then check every field before you print.

Open the viewer

Frequently asked questions

How do I make text bold in ZPL?

Font 0 is already bold. For extra weight, use a larger width, print the field twice offset by one or two dots, or use reverse printing on a filled box.

How do I centre text on a ZPL label?

Use a field block the width of the label with C justification, for example ^FO0,100^FB812,1,0,C^FDTitle^FS on a 4 inch label at 203 dpi.

Why does my text overlap at the end of a field block?

The text needs more lines than the block allows. Increase the second ^FB parameter, reduce the font size or widen the block.

How do I add a line break in ZPL text?

Inside a ^FB field block, write \& where the new line should start. Outside a field block, use separate fields.

Sources and further reading

Written by the ZPL Viewer Editorial Team

We build and maintain the ZPL Viewer rendering engine and write these guides from real testing of label code. Every example in this article was rendered in our viewer before publishing. Read more about how we work.