Skip to main content

Python SDK for Star TSP100 Graphic Mode thermal printers

Project description

py-star-tsp

Python SDK for Star thermal printers operating in Graphic Mode over USB.

Following the STAR Graphic Mode Command Specifications Rev. 2.31.

AI Generated, poorly reviewed, and hardly supervised.

Supported Models

Model Interface Tested
TSP100U USB -
TSP100PU USB + Parallel -
TSP100GT USB + Ethernet -
TSP100LAN Ethernet -
TSP100IIU USB Y
TSP100IIIW USB + Wi-Fi -
TSP100IIILAN USB + Ethernet -
TSP100IIIBI USB + Bluetooth -
TSP100IIIU USB -

Installation

pip install .

Linux USB Access (udev rule)

By default, USB devices are accessible only to root. Add the following udev rule to grant access to all users in the plugdev group:

# /etc/udev/rules.d/99-star-tsp100.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="0519", MODE="0666", GROUP="plugdev"

Reload rules and reconnect the printer:

sudo udevadm control --reload-rules
sudo udevadm trigger

Add your user to the plugdev group if necessary:

sudo usermod -aG plugdev $USER

Font Discovery and Fallback

The text renderer automatically scans standard OS directories for .ttf and .otf fonts:

OS Search paths
Linux /usr/share/fonts, /usr/local/share/fonts, ~/.local/share/fonts, ~/.fonts
macOS /System/Library/Fonts, /Library/Fonts, ~/Library/Fonts
Windows %WINDIR%\Fonts

You can also set the FONTPATH environment variable to add custom directories (separated by os.pathsep).

Fallback font order

When no specific font is requested, the following are tried in order:

  1. DejaVu Sans Mono
  2. Liberation Mono
  3. FreeMono
  4. Arial
  5. Consolas
  6. Courier New

If no TrueType/OpenType fonts are found at all, Pillow's built-in bitmap font is used. This bitmap font does not support sizing, bold, italic, or underline — a warning is logged.

Font source packages

Install these Python/system packages to ensure fonts are available:

  • matplotlib — ships DejaVu Sans / DejaVu Sans Mono
  • fonttools — useful for font metadata inspection
  • fonts-dejavu (Debian/Ubuntu) / dejavu-sans-mono-fonts (Fedora/Rocky) — DejaVu family
  • fonts-liberation (Debian/Ubuntu) / liberation-mono-fonts (Fedora/Rocky) — Liberation family

Midtones / Grayscale (Dithering)

TBD

Preview / Export

You can save the queued raster output to an image file before sending it to the printer.

from py_star_tsp import StarTSP

printer = StarTSP()
printer.add_text("Preview me")
printer.add_bar(width=576, height=8)

printer.save_rendered("preview.bmp")
printer.save_rendered("preview.jpg", quality=95)

image = printer.render_image()
print(image.size)

Use BMP if you want an exact 1-bit preview of what will be sent to the printer. JPEG is supported too, but it is exported as grayscale because JPEG does not support 1-bit images.

ESC/POS Compatibility

TBD

Specification Reference

Commands are implemented from the STAR Graphic Mode Command Specifications Rev. 2.31 (star_graphic_cm_en.pdf).

Licensing

  • Kitten in the demos by Deni Sudibyo

TODO

  • 2d code implementation (barcode, qr, etc)
  • Python version compatibility
  • ESC/POS compatibility (very long term)
  • Usage with external rendering (just printing ready to use raster)
  • Turn demo to a reference sheet
  • Generate a preview of what's rendered to be printed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_star_tsp-1.0.0.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_star_tsp-1.0.0-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

Details for the file py_star_tsp-1.0.0.tar.gz.

File metadata

  • Download URL: py_star_tsp-1.0.0.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_star_tsp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 deb5b4e747a77b14de316b510408c12d0c1031a4e3746013fcd8fe570dbdc305
MD5 ad8073d3eb8ee6624e85a02770608b36
BLAKE2b-256 6aac0453ff1bbb28dbbf25d46e13ed84829477014a0b399968ab1c6255fdc4af

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_star_tsp-1.0.0.tar.gz:

Publisher: release.yml on printer-stream/py-star-tsp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_star_tsp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_star_tsp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 48.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_star_tsp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4b547fc744acb469da2a5b65dadda523af4bb3a1be3e89e85257e011c28c223
MD5 3bef96689f227d1aa50e04b2b3c4ba00
BLAKE2b-256 46cff5f9386a30dc5780454198961bac690e19829952a8112260a6786e729aa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_star_tsp-1.0.0-py3-none-any.whl:

Publisher: release.yml on printer-stream/py-star-tsp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page