ZPL emulator custom font (~DU command) in Python (File to bytes to hex)

121 Views Asked by At

So I've been raking my brain on this for a while now : I'm trying to upload a custom font to a ZPL printer using the ~DU command in python, but can't get the encoding right.

This is what I'm currently doing:

font = f.read()
byte_data = binascii.hexlify(font)
fontString = str(byte_data)
stringSize = len(byte_data)

I then modify currently existing ZPL to add the ~DU command as such :

ZPL = ZPL + '~DUR:FONT.FNT,' + str(stringSize) + ',' + fontString
ZPL = ZPL + '^CWA,R:FONT.FNT'

I've seen people do the same thing here: Using ttf font in Labelary api via c# so I'm wondering if I didn't screw up my python equivalent. Any help would be greatly appreciated

1

There are 1 best solutions below

0
Billy Bob On

Disregard this as I am very, very stupid and was replacing the wrong label font in the ^CWA command. If anyone stumbles upon this - this works.