zplCore.comzplCore.com

09Fonts

Font 0 ≈ Swiss 721 Bold Condensed via the embedded Roboto Condensed Bold (OFL), calibrated to Zebra metrics (cap height 0.735·h, cap top at ^FO); measured within 1–3 dots of the Labelary output. The bitmap fonts A–H use DejaVu Sans Mono with Zebra advance (cell width + spacing) × magnification. Your own TTFs replace them or are added via ^A@.

More on zplCloud.com: Guide: Fonts in ZPL · Blog: SVG to TTF: logos and icons as a printer font

var renderer = new ZplRenderer();
FontManager fonts = renderer.Store.Fonts;

fonts.RegisterFont("0", File.ReadAllBytes("MyZebraLike.ttf"));   // replace font 0
fonts.RegisterFont("E:ARIAL.TTF", File.ReadAllBytes("arial.ttf"));  // for ^A@N,..,E:ARIAL.TTF
fonts.RegisterFolder("fonts/");                                   // 0.ttf, A.ttf, ... PLATE.TTF
fonts.LinkFont("E:ARIAL.TTF", "E:NOTOCJK.TTF");                   // like ^FL: fallback glyphs

renderer.ProcessCommands("^XA^CI28^FO50,50^A@N,40,40,E:ARIAL.TTF^FDÄrger? Nö!^FS^XZ");

Download via ZPL

~DYE:MONO,A,T,size,,hex or ~DUE:MONO.TTF,size,hex loads a TTF into printer memory; ^A@N,40,40,E:MONO.TTF uses it, ^CW assigns a letter alias.

Label model

label.AddFont("MONO.TTF", bytes) embeds the font: ToZpl() sends it via ~DY, JSON stores it as well.

Complex scripts, bidi & fallback

Text is shaped with HarfBuzz: Arabic ligatures, Hebrew and Arabic right-to-left rendering (bidi), Devanagari and Thai combining marks. If glyphs are missing, a suitable system font is found automatically (CJK, Thai, Hindi …). ^PA turns shaping/bidi off, ^FL (or FontManager.LinkFont) links an extension font to a base font.

^XA^FLE:NOTOCJK.TTF,E:ARIAL.TTF,1^XZ     ← take glyphs missing in ARIAL from NOTOCJK
^XA^FLE:NOTOCJK.TTF,E:ARIAL.TTF,0^XZ     ← remove the link

~DB bitmap fonts

Bitmap fonts downloaded with ~DB are drawn glyph-exact and magnified by integer factors; usable via ^A@…,R:NAME.FNT or a ^CW alias.

PrintAsGraphic

For printers without memory for TTFs: PrintAsGraphic = true renders the element (barcodes too) in the preview engine and sends it as ^GFA. Pixel-identical to direct TTF rendering – verified in tests.

var label = new Label(LabelUnit.Dots, 600, 200) { DownloadFonts = false }
    .AddFont("MONO.TTF", File.ReadAllBytes("DejaVuSansMono.ttf"))
    .Add(new TextItem
    {
        X = 20, Y = 20, Font = "E:MONO.TTF", Text = "TTF als Grafik", FontSize = 22,
        PrintAsGraphic = true,                // text is sent as ^GFA
    });

string zpl = label.ToZpl();                   // contains ^GFA, no ~DY and no ^A@