4

Is there a way to calculate the total width of Zebra Font 0 given text? Consider the following ZPL command,

**^XA^FO100,150^A030,30^FDSample Text^FS^XZ**

Here both character height and width is 30 dots. I want to calculate the actual width of this text in mm. Please note that printer DPI is 300..............

1 Answer 1

5

Font 0 is a variable-width font (not monospaced like some of the others), so the width of the text will depend on the text itself.

One option would be to switch to a built-in monospaced font like font C, where each character is always 10 dots wide and the intercharacter gap is 2 dots wide (see the Zebra Programming Guide, page 1212 table 32 and page 1216 table 35). If your printer is 300 DPI, then it's 12 dpmm (dots per millimeter), and you can just do the math from there based on how many characters you have (and how many gaps between them):

"Sample Text" length = 11 characters

Intercharacter gaps = 11 - 1 = 10 intercharacter gaps

(11 characters * 10 character width) + (10 intercharacter gaps * 2 gap width) = 130 dots

130 dots / 12 dpmm = 10.8 mm

However, if you really want to use font 0, and if you know what text you want to measure, then you can try drawing a box around it using ^GB to get a rough approximation of the width.

Here's an example using your sample text, which seems to indicate that it's about 112 dots wide. At your density (12 dots per millimeter), that's a little over 9 millimeters.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, @Abel. Just wanted to provide an update for people who are here for a first time. It is now on page 1312, within Table 33 • Intercharacter Gap and Baseline Parameters. To change a font, you can use the ^A command, in example for font F: ^AFN,26,13. The 26 and the 13 are from Table 33, and correspond to height and width for font F.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.