zXynK
zXynK

Reputation: 1332

ZPL Viewer rendering monospace hyphens

For this ZPL:

^XA
^LH0,0
^CI28
^MNN
^LL1054
^AF,30^FO16,206^FB544,1,0,C,0^FH^FDINVOICE NO: INV-1008\&^FS
^AF,30^FO16,268^FB544,1,0,L,0^FH^FDDN-1006\&^FS
^XZ

I would expect all the characters to be the same width, as the specified font is a monospace font.

In fact, when rendering it via https://labelary.com/viewer.html the image looks as I'd expect:

renders via online viewer

But when rendering via the .NET library as referenced here, the image turns out different. Most notable, the hyphens appear to take up 3 character spaces:

render via .net

As you can see, the hyphens are much wider or are adding more space around them.

I'm certain there are no spaces. What do I need to do to allow them to render the same? Should I replace the '-' character?

Thanks

Upvotes: 1

Views: 92

Answers (1)

zXynK
zXynK

Reputation: 1332

So after having a look through the code here it seems like there is a flag called ReplaceDashWithEnDash which defaults to true, that adds in the spaces around the hyphen

Settings the options removed the spaces:

        IPrinterStorage printerStorage = new PrinterStorage();
        var drawer = new ZplElementDrawer(printerStorage, new()
        {
            OpaqueBackground = addWhiteBackground,
            ReplaceDashWithEnDash = false
        });

It still doesn't look exactly like the Labelary viewer, but it suits my purposes.

Thanks

Upvotes: 1

Related Questions