How to calculate the font width, ZPL

M Mariusz P. 3 years 7 months ago
1054 1 0

I wanted to ask how the font width is calculated?
For example, in the ZebraDesigner program, I have a 12 pt field, the Zebra0 font
in ZPL language: ^A0I,34,33
For 203 DPI: 12 * 203 / 72 = 34
But how is the value "33" calculated?
The average character width for Zebra0 12 pt is 4 (GetTextMetrics), but I do not know how to calculate it.

Please Register or Login to post a reply

1 Replies

E Efkan YILMAZ

Hi Marius,  A font pt field is an approximation and differs slightly for all fonts.  This program is taking some of that variabilty into account in the calculation.  A 12pt font should (at 200DPI) be exactly 34x34 but in reality, it isn't.

It is really very difficult to determine the printed length of a string using most fonts. If you are using a monospace font, you can do it as all the characters would be the same size, but most fonts are not monospace. The font 0 in Zebra printers is not monospace. See this example:

IIIII   MMMMM
----   -------------

The 'I' character takes up much less room than the 'M'.  If your text is natural language, it is nearly impossible to calculate the exact length.  You can either switch to a monospace font, or give yourself some allowance for the variability. If you are doing multiline, consider using the ^TB or ^FB commands to handle it for you.

CONTACT
Can’t find what you’re looking for?