diff --git a/src/components/Canvas/BarcodeObject.tsx b/src/components/Canvas/BarcodeObject.tsx index 470ff06..4864c43 100644 --- a/src/components/Canvas/BarcodeObject.tsx +++ b/src/components/Canvas/BarcodeObject.tsx @@ -3,7 +3,7 @@ import bwipjs from "bwip-js/browser"; import { Image as KImage, Group, Rect, Text } from "react-konva"; import type Konva from "konva"; import type { LabelObject } from "../../registry"; -import { BARCODE_1D_TYPES } from "../../registry"; +import { BARCODE_1D_TYPES, ObjectRegistry } from "../../registry"; import type { ObjectChanges } from "../../store/labelStore"; import { dotsToPx, pxToDots } from "../../lib/coordinates"; import { @@ -144,8 +144,12 @@ export function BarcodeObject({ if (barcodeCanvas) { const w = displayW; const h = displayH; - const printInterp = !!(obj.props as { printInterpretation?: boolean }) - .printInterpretation; + // Force-off when the symbology has no HRI in ZPL (e.g. GS1 Databar) — the + // canvas must match the print output even if a legacy saved object still + // carries printInterpretation: true. + const printInterp = + !ObjectRegistry[obj.type]?.interpretationLocked && + !!(obj.props as { printInterpretation?: boolean }).printInterpretation; const moduleWidth = (obj.props as { moduleWidth?: number }).moduleWidth ?? 2; const textFontSize = Math.max(dotsToPx(moduleWidth * 10, scale, dpmm), 6); @@ -435,9 +439,7 @@ export function BarcodeObject({ } // ── Other 1D: separate Konva Text below bars ────────────────────────── - const showText = - BARCODE_1D_TYPES.has(obj.type) && - (obj.props as { printInterpretation?: boolean }).printInterpretation; + const showText = BARCODE_1D_TYPES.has(obj.type) && printInterp; let displayText = rawContent; if (obj.type === "code39") { diff --git a/src/registry/barcode1d.tsx b/src/registry/barcode1d.tsx index 88fa809..6ee0421 100644 --- a/src/registry/barcode1d.tsx +++ b/src/registry/barcode1d.tsx @@ -32,6 +32,8 @@ interface Barcode1DConfig { byRatio?: number; /** See {@link ObjectTypeDefinition.heightLocked}. */ heightLocked?: boolean; + /** See {@link ObjectTypeDefinition.interpretationLocked}. */ + interpretationLocked?: boolean; } interface BarcodeLocale { @@ -52,16 +54,22 @@ export function createBarcode1D(config: Barcode1DConfig): ObjectTypeDefinition { - const p = obj.props; + // Normalize printInterpretation for symbologies that have no HRI in ZPL + // (e.g. ^BR). This protects against legacy saved objects that still carry + // printInterpretation: true from emitting an out-of-spec interpretation flag. + const p = config.interpretationLocked + ? { ...obj.props, printInterpretation: false } + : obj.props; const byCmd = config.byRatio !== undefined ? `^BY${p.moduleWidth},${config.byRatio}` : `^BY${p.moduleWidth}`; @@ -115,15 +123,17 @@ export function createBarcode1D(config: Barcode1DConfig): ObjectTypeDefinition - + {!config.interpretationLocked && ( + + )} {config.hasCheckDigit && (