mirror of
https://github.com/python-escpos/python-escpos
synced 2025-06-25 08:38:43 +00:00
![dependabot[bot]](/assets/img/avatar_default.png)
* Bump sphinx-rtd-theme from 2.0.0 to 3.0.1 Bumps [sphinx-rtd-theme](https://github.com/readthedocs/sphinx_rtd_theme) from 2.0.0 to 3.0.1. - [Changelog](https://github.com/readthedocs/sphinx_rtd_theme/blob/master/docs/changelog.rst) - [Commits](https://github.com/readthedocs/sphinx_rtd_theme/compare/2.0.0...3.0.1) --- updated-dependencies: - dependency-name: sphinx-rtd-theme dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * remove call to get_html_theme_path according to deprection warning of sphinx-rtd-theme>=3 * disable broken spelling integration (pypi) and fix spelling * fix spelling --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
73 lines
1.4 KiB
Python
73 lines
1.4 KiB
Python
"""Prints code page tables."""
|
|
|
|
|
|
import sys
|
|
|
|
from escpos import printer
|
|
from escpos.constants import (
|
|
CODEPAGE_CHANGE,
|
|
CTL_CR,
|
|
CTL_FF,
|
|
CTL_HT,
|
|
CTL_LF,
|
|
CTL_VT,
|
|
ESC,
|
|
)
|
|
|
|
|
|
def main():
|
|
"""Init printer and print codepage tables."""
|
|
dummy = printer.Dummy()
|
|
|
|
dummy.hw("init")
|
|
|
|
for codepage in sys.argv[1:] or ["USA"]:
|
|
dummy.set(height=2, width=2)
|
|
dummy._raw(codepage + "\n\n\n")
|
|
print_codepage(dummy, codepage)
|
|
dummy._raw("\n\n")
|
|
|
|
dummy.cut()
|
|
|
|
print(dummy.output)
|
|
|
|
|
|
def print_codepage(printer, codepage):
|
|
"""Print a code page."""
|
|
if codepage.isdigit():
|
|
codepage = int(codepage)
|
|
printer._raw(CODEPAGE_CHANGE + bytes((codepage,)))
|
|
printer._raw("after")
|
|
else:
|
|
printer.charcode(codepage)
|
|
|
|
sep = ""
|
|
|
|
# Table header
|
|
printer.set(font="b")
|
|
printer._raw(f" {sep.join(map(lambda s: hex(s)[2:], range(0, 16)))}\n")
|
|
printer.set()
|
|
|
|
# The table
|
|
for x in range(0, 16):
|
|
# First column
|
|
printer.set(font="b")
|
|
printer._raw(f"{hex(x)[2:]} ")
|
|
printer.set()
|
|
|
|
for y in range(0, 16):
|
|
byte = bytes(
|
|
(x * 16 + y),
|
|
)
|
|
|
|
if byte in (ESC, CTL_LF, CTL_FF, CTL_CR, CTL_HT, CTL_VT):
|
|
byte = " "
|
|
|
|
printer._raw(byte)
|
|
printer._raw(sep)
|
|
printer._raw("\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|