Label printers (TSPL/TSPL2) — experimental
Branch experimental/tspl2. Receipt printers (ESC/POS) behave exactly as before; this only adds a second output language for label printers such as the Altec ATP-300 Pro (USB 1203:0231, MFG:Altec;CMD:TSPL2;MDL:ATP-300 Pro;).
Protocol detection (automatic)
1. The printer's IEEE 1284 device ID (CMD: field): read from Linux sysfs (ieee1284_id) or with the USB printer-class GET_DEVICE_ID request. TSPL* → TSPL. If ESC/POS is also listed, ESC/POS is used. 2. No device ID but USB vendor 0x1203 (TSC/Altec) → TSPL. 3. Windows queue name containing TSPL, Altec ATP or TSC → TSPL. 4. Otherwise ESC/POS (unchanged default).
Label format
The print dialog shows a Label printer section only for TSPL printers. The first time a model is used it asks width, height, gap/black mark/continuous, resolution and rotation, pre-filled from the printer when it answers GETSETTING$("CONFIG","TSPL","PAPER WIDTH" / "PAPER SIZE" / "GAP SIZE") and GETSETTING$("SYSTEM","INFORMATION","DPI") over bidirectional USB (values are only used when the reply has an explicit unit). The format is stored per model in label_formats.json next to config.json. "Let the printer measure the labels first" sends GAPDETECT x,y / BLINEDETECT x,y once.
Output
The page is encoded with the unchanged ESC/POS encoder, rendered to a bitmap (Font A 12×24 grid, alignment, double size, bold, raster images, barcodes, QR), scaled to the label resolution (8 → 12 dots/mm at 300 dpi, shrunk to fit the label width), centred, split over labels (@cut = next label, long pages over several labels) and sent as:
SIZE w mm,h mm
GAP g mm,0 mm (BLINE g mm,0 mm / GAP 0,0)
DIRECTION 0,0
REFERENCE 0,0
CLS
BITMAP x,0,wbytes,h,0,<1-bit data, 0 = black>
PRINT 1,1
cargo run --example tspl_preview -- file.pos out 100 50 3 300 writes PNG previews and the .prn job without a printer.
Source
| 1 | # Label printers (TSPL/TSPL2) — experimental |
| 2 | |
| 3 | Branch `experimental/tspl2`. Receipt printers (ESC/POS) behave exactly as before; |
| 4 | this only adds a second output language for label printers such as the |
| 5 | Altec ATP-300 Pro (USB 1203:0231, `MFG:Altec;CMD:TSPL2;MDL:ATP-300 Pro;`). |
| 6 | |
| 7 | ## Protocol detection (automatic) |
| 8 | |
| 9 | 1. The printer's IEEE 1284 device ID (`CMD:` field): read from Linux sysfs |
| 10 | (`ieee1284_id`) or with the USB printer-class `GET_DEVICE_ID` request. |
| 11 | `TSPL*` → TSPL. If ESC/POS is also listed, ESC/POS is used. |
| 12 | 2. No device ID but USB vendor 0x1203 (TSC/Altec) → TSPL. |
| 13 | 3. Windows queue name containing `TSPL`, `Altec ATP` or `TSC` → TSPL. |
| 14 | 4. Otherwise ESC/POS (unchanged default). |
| 15 | |
| 16 | ## Label format |
| 17 | |
| 18 | The print dialog shows a *Label printer* section only for TSPL printers. The |
| 19 | first time a model is used it asks width, height, gap/black mark/continuous, |
| 20 | resolution and rotation, pre-filled from the printer when it answers |
| 21 | `GETSETTING$("CONFIG","TSPL","PAPER WIDTH" / "PAPER SIZE" / "GAP SIZE")` and |
| 22 | `GETSETTING$("SYSTEM","INFORMATION","DPI")` over bidirectional USB (values are |
| 23 | only used when the reply has an explicit unit). The format is stored per model |
| 24 | in `label_formats.json` next to `config.json`. "Let the printer measure the |
| 25 | labels first" sends `GAPDETECT x,y` / `BLINEDETECT x,y` once. |
| 26 | |
| 27 | ## Output |
| 28 | |
| 29 | The page is encoded with the unchanged ESC/POS encoder, rendered to a bitmap |
| 30 | (Font A 12×24 grid, alignment, double size, bold, raster images, barcodes, QR), |
| 31 | scaled to the label resolution (8 → 12 dots/mm at 300 dpi, shrunk to fit the |
| 32 | label width), centred, split over labels (`@cut` = next label, long pages over |
| 33 | several labels) and sent as: |
| 34 | |
| 35 | ``` |
| 36 | SIZE w mm,h mm |
| 37 | GAP g mm,0 mm (BLINE g mm,0 mm / GAP 0,0) |
| 38 | DIRECTION 0,0 |
| 39 | REFERENCE 0,0 |
| 40 | CLS |
| 41 | BITMAP x,0,wbytes,h,0,<1-bit data, 0 = black> |
| 42 | PRINT 1,1 |
| 43 | ``` |
| 44 | |
| 45 | `cargo run --example tspl_preview -- file.pos out 100 50 3 300` writes PNG |
| 46 | previews and the `.prn` job without a printer. |