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:
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.
Thank you for your answer. However, I am interested in some formula to calculate the width parameter.
I do not want to determine the printed length of a string.
Let's assume that for ^A0I,34,33 x = 34 and y = 33
Parameters x and y does not depend on what I write in the text field (and from the length of the text).
According to documentation for zebra0 font matrix h x w (in dots) = 15 x 12
So for x = 34, y should be 27 not 33. Am I understand it correctly?
I want to write a program for analyzing ZPL files and I would like to detect if the user
changed the width of the text field in ZebraDesigner and how much.
I want to replace this ^A parameter with graphic field ^GF and I want to know the font width.