Repository navigation
feat(printers): gate Arabic and Persian thermal output behind shaping capability - #355
Merged
Merged
Conversation
Add an explicit `arabicShaping` capability flag to printer profiles and thread it through every raw ESC/POS encoder (receipt, plugin template, and KOT). Arabic/Persian script is now only emitted when the profile declares shaping support; otherwise it is skipped with a precise warning and financial lines keep their ASCII currency fallback (ریال → IRR), so corrupted or unshaped glyphs can never reach the printer. Defaults to off (safe) for every existing profile, matching the #273 financial-line protection. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <[email protected]>
khaira777
enabled auto-merge (squash)
August 17, 2026 21:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Move Persian raw thermal receipt printing beyond the narrow #273 financial-line protection and determine correct supported behavior. Generic ESC/POS firmware does not shape Arabic/Persian, so Persian text must never be emitted as corrupted/unshaped glyphs: gate Arabic-script thermal output behind an explicit per-printer 'arabicShaping' capability flag that defaults to off (safe fallback skips Arabic text with a precise warning while financial lines keep their ASCII currency fallback such as riyal-to-IRR), thread that flag through every raw ESC/POS encoder (receipt, plugin template, KOT) on the backend and mirror the precise warning on the frontend WebUSB path, and add deterministic tests for the Persian path, unsupported Persian path, mixed-script path, financial-line safety, narrow widths, large values, and existing non-Persian behavior. Do not add a large raster-printing subsystem. Meva TP-UN capability cannot be proven without a real hardware print, so mark it needs-human-verification.
What Changed
arabicShapingcapability flag toSupportedPrinterProfile(defaulting to false) and gated Arabic and Persian script raw ESC/POS output behind it across receipt, plugin template, and KOT formatters.tests/printer.test.tsverifying default skipping with shaping-specific warnings, successful output whenarabicShapingis enabled, and mixed-script safeguards.Risk Assessment
✅ Low: The change safely gates Arabic/Persian thermal printing behind an explicit capability flag defaulting to off, preserves ASCII financial-line fallbacks, provides precise warnings across backend and frontend paths, and includes comprehensive test coverage with zero regressions.
Testing
Exercised the full printer test suite and targeted ESC/POS encoder validations across backend thermal receipts, plugin templates, KOTs, and frontend WebUSB warning paths, verifying that Persian text is safely skipped with precise shaping warnings under generic profiles, rendered cleanly when explicit arabicShaping is enabled, and that large IRR financial amounts and narrow 58mm layouts remain aligned; generated reviewer-visible visual HTML preview and text comparison artifacts with all 313 assertions passing.
Evidence: Persian Thermal Fallback & Arabic Shaping CLI Evidence
Evidence: Rendered Visual Receipt Simulation & Warnings Preview (HTML)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npx ts-node --transpile-only -P tests/tsconfig.json tests/printer.test.tsnpm run test:printer-apinpx ts-node --transpile-only -P tests/tsconfig.json tests/receipt-column-width.test.tsnode tests/run-electron-node-test.cjs tests/receipt-printing.test.tsnode tests/run-electron-node-test.cjs tests/bills-print-api.test.tsEnd-to-end receipt and KOT rendering verification comparing default generic ESC/POS printers (arabicShaping: false) against shaped hardware profiles (arabicShaping: true)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.