I am trying to find out if there is a possible way via which we can convert the X/Y coordinates from the ^FO
command to the equivalent ^FT
coordinates in such a way that the position of text in the label does not change.
I see that the only difference between the two commands is that position is that the text would be printed from top to bottom from the specified X/Y coordinates when we use the ^FO
command, while using ^FT
command would print it from bottom to top from the specified coordinates (see example below).
ZPL Code:
^XA
^CI0
^FT100,50^A0N,50,50^FDSAMPLE TEXT^FS
^FO100,50^A0N,50,50^FDSAMPLE TEXT^FS
^XZ
Output:
Now, if I want to print the text exactly at the same position in the label then I will need to adjust the Y-coordinate value but I am not able to figure out any formula via which same can be done.
I have tried setting the Y-coordinate of ^FT
command = Y-coordinate of ^FO
command + height (which is 50 + 50 = 100 in above case) but this doesn't seem to resolve the issue.
Any thoughts on the same would be greatly appreciated.
I have tried setting the Y-coordinate of ^FT command = Y-coordinate of ^FO command + height
This approach is correct in general, but you are adding too much. You are adding the entire height of the character cell (that is what the 50 in ^A0,50
means), while ^FT
works off the baseline of the font, and the baseline is not at the bottom of the character cell. You need to calculate yourself where it is.
As the ZPL manual tells you on page 1413, for the proportional font (^A0
) the baseline height is 3 * cell height / 4. Your cell height is 50, so that gives you 37.5. This is what you should add to your ^FO
Y-coordinate.
^XA
^CI0
^FT100,87^A0N,50,50^FDSAMPLE TEXT^FS
^FO100,50^A0N,50,50^FDSAMPLE TEXT^FS
^XZ