Skip to content

research(printing): evaluate bidi, shaping, and raster fallback for non-Latin thermal printers #446

Closed

Description

@khaira777

Refs: #438
Depends on: #439
Can parallel with: B, C, D, E, F, G, I, J
Related: #206 (Windows raw-print history), #241

Context

Raw thermal printing of Persian/Arabic — and non-Latin scripts generally — currently relies on a per-profile arabicShaping passthrough plus line-skipping with warnings (#437 era). That is a stopgap. The community needs an evidence-based decision about how FloCafe should render non-Latin scripts on ESC-POS hardware across its transports.

This is a research issue with a mandated deliverable: a written capability study + decision record, optionally a flag-gated prototype of the leading candidate. Time-to-implement is explicitly NOT a decision criterion; technical correctness and hardware compatibility are.

Architectural Decisions Relevant to This Issue

  • No silent data loss is the end-state contract; this research determines which mechanism achieves it for raw printers.
  • Any dependency (e.g., an Arabic shaping/bidi library) requires standalone evaluation here — never bundled into label/policy PRs.
  • Techniques must generalize beyond Persian (Arabic, Hebrew, CJK, Hindi, Thai, mixed scripts).

Scope / What to do

Produce docs/printing-nonlatin-capabilities.md comparing, with code-level and hardware evidence:

Approach Evaluate
Printer-native Arabic/Persian shaping firmware requirements, existing arabicShaping profile flag reality
Printer-native codepages (CP1256/CP720/…) glyph coverage, isolated-form problem, per-vendor variance
UTF-8 pass-through behavior which models accept it; mojibake modes
Host-side shaping + bidi reordering pre-emission correctness on dumb UTF-8 printers; interaction with truncation/column math; dependency quality (license, size, maintenance); mixed-script rows
Raster per-line / per-block / whole-receipt fidelity vs speed vs driver quirks; WebUSB/TCP/spooler support; memory constraints
HTML/browser fallback current baseline; when to steer users

For each: printer requirements, visual fidelity, mixed-script correctness, performance, paper-width/layout consequences, transport support matrix (WebUSB vs TCP vs OS spooler), package-size impact, maintenance burden, failure/fallback mode.

Deliverables:

  1. Decision record recommending primary + fallback strategy per transport.
  2. Prototype behind a default-OFF flag/env for the top candidate IF contained in the spike branch (no dependency added to package.json without separate review approval in the PR).
  3. A community hardware-test matrix checklist so owners of real printers can report results.
  4. Follow-up implementation issue draft (created only after study lands).

Compatibility / Migration

None directly (flag default-off). Study must state migration implications for the legacy skip-with-warning path.

What NOT to do

  • Do NOT integrate any technique into production renderers under this issue.
  • Do NOT add runtime dependencies to app bundles from the spike.
  • Do NOT justify choices by implementation speed ("≤2 days" style reasoning is invalid).
  • Do NOT change arabicShaping semantics or profiles while studying.

Acceptance Criteria

  • Study doc covers all seven approaches × all listed criteria with cited evidence (specs, datasheets, code paths, test prints).
  • Explicit recommendation per transport + explicit open questions requiring hardware.
  • Prototype (if included) is flag-gated off, documented, and removable.
  • Hardware test matrix published for community validation.
  • Follow-up implementation issue drafted with scope boundaries.

Verification

npm run build && npm run lint   # prototype compiles; docs link-check

Manual: prototype print samples on at least one real printer if available to author; otherwise document that gap explicitly.

Documentation

The study doc IS the deliverable; link it from epic and printers docs.

Metadata

Metadata

Assignees

Labels

area:backend

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions