Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions pi-clients/printer/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,33 @@ def render(printer: _EscposLike, payload: PrintPayload, width: int = 32) -> None
if width < 16:
width = 16 # paranoia: don't divide by zero in layout math

# ---- title (double height + bold, centered) -------------------
printer.set(align="center", bold=True, double_height=True, double_width=False)
printer.text(_truncate(payload.title, width) + "\n")
printer.set(align="center", bold=False, double_height=False, double_width=False)

# ---- subtitle (centered, normal) ------------------------------
is_ticket = payload.format == "ticket"

# ---- title -----------------------------------------------------
# Tickets get a chunkier title (double width + double height) so they
# read at arm's length on the fridge. Lists keep the slimmer look that
# fits more lines per inch of paper.
if is_ticket:
printer.set(align="center", bold=True, double_height=True, double_width=True)
# Double-width chars take 2 cols, so the practical width halves.
printer.text(_truncate(payload.title, width // 2) + "\n")
else:
printer.set(align="center", bold=True, double_height=True, double_width=False)
printer.text(_truncate(payload.title, width) + "\n")

# ---- subtitle --------------------------------------------------
if payload.subtitle:
printer.text(_truncate(payload.subtitle, width) + "\n")
if is_ticket:
# Bold + double-height (not double-width) — bigger date without
# eating two paper rows of vertical space.
printer.set(align="center", bold=True, double_height=True, double_width=False)
printer.text(_truncate(payload.subtitle, width) + "\n")
else:
printer.set(align="center", bold=False, double_height=False, double_width=False)
printer.text(_truncate(payload.subtitle, width) + "\n")

# Reset to plain and draw the divider.
printer.set(align="center", bold=False, double_height=False, double_width=False)
printer.text("-" * width + "\n")

# ---- body lines ----------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions pi-clients/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
supabase>=2.5.0,<3
pydantic>=2.6,<3
python-escpos>=3.0,<4
# python-escpos lists pyusb as an optional dep; without it the USB backend
# fails at runtime with "Printing with USB connection requires a usb library
# to be installed". Pin it explicitly so installs don't drift.
pyusb>=1.2,<2
pyserial>=3.5,<4
evdev>=1.6,<2 ; sys_platform == "linux"
python-dotenv>=1.0,<2