diff --git a/packages/devices/src/drivers/printer-escpos.ts b/packages/devices/src/drivers/printer-escpos.ts index 7a1f000..790633f 100644 --- a/packages/devices/src/drivers/printer-escpos.ts +++ b/packages/devices/src/drivers/printer-escpos.ts @@ -123,14 +123,13 @@ function line(text = ""): Buffer { * `moduleWidth` (narrow-bar dots, 1–6) trades scan-tolerance for total width: at ~11 * modules/char a 13-char id fits 80mm (576 printable dots) at width 3, but a ~20-char * id needs width 2 or it OVERFLOWS the head and the firmware silently aborts the - * barcode (prints nothing). Keep the symbol LEFT-aligned — centering shifts the start - * point right and makes a wide barcode overflow even sooner. */ + * barcode (prints nothing). It does NOT set alignment — the caller does (a barcode that + * FITS the head centers fine; the no-print bug was width, not centering). */ function code128(data: string, moduleWidth = 3): Buffer { // Code128 code set B (printable ASCII) — prefix the data with the {B selector. const payload = Buffer.from(`{B${data}`, "ascii"); const w = Math.max(1, Math.min(6, moduleWidth)); return Buffer.concat([ - ALIGN_LEFT, // a wide barcode must start at the left margin to fit the 80mm head Buffer.from([GS, 0x68, 0x64]), // GS h 100 — barcode height = 100 dots (taller = tolerant of scan angle) Buffer.from([GS, 0x77, w]), // GS w n — module (narrow-bar) width in dots Buffer.from([GS, 0x48, 0x00]), // GS H 0 — HRI text off (we print the id ourselves) @@ -425,12 +424,10 @@ export function renderReceipt(data: ReceiptData): Buffer { ]; if (data.voucher) { - // The same ticket id, scannable at the exit reader, + the grace emphasis. code128 - // forces ALIGN_LEFT (a wide barcode must hug the margin); restore centering for the - // human-readable id + grace lines that follow. + // The same ticket id, scannable at the exit reader, + the grace emphasis. The block + // is ALIGN_CENTER (set at the amount above), so the barcode + id center as before. parts.push( code128(data.ticketId), - ALIGN_CENTER, line(), line(data.ticketId), line(), @@ -466,14 +463,13 @@ export function renderWindowChargeNotice(data: WindowChargeNoticeData): Buffer { line(STR.windowTitle), BOLD_OFF, line(), - // The occurrence id, scannable two ways. Code128 for a 1D laser scanner FIRST — - // module width 2 + left-aligned (code128 forces ALIGN_LEFT) because the ~20-char - // occurrence id is too wide to fit the 80mm head at width 3 (the firmware would - // abort it). Then the QR for the booth's combo reader. Either pulls the occurrence - // up in the pay modal. + // The occurrence id, scannable two ways, both CENTERED (the surrounding block is + // ALIGN_CENTER). Code128 for a 1D laser scanner FIRST — module width 2 because the + // ~20-char occurrence id is too wide to fit the 80mm head at width 3 (the firmware + // would abort it); at width 2 (~510 dots) it fits and centers fine. Then the QR for + // the booth's combo reader. Either pulls the occurrence up in the pay modal. code128(data.occurrenceId, 2), line(), - ALIGN_CENTER, qrCode(data.occurrenceId), line(), // The id in text, as the hand-key fallback if neither scans.