Test page: replace inverted section banners with plain '=' rules, frame page with '-'
deploy / deploy (push) Successful in 10s

Matches the style settled on for the print-issues receipt -- '=' for
labeled section breaks, '-' for the plain top/bottom frame, no more
fully blacked-out rows.
This commit is contained in:
randy committed 2026-09-13 12:40:00 +02:00
1 parent a58d4b66ea
commit 4308850a2e
2 files changed
+18 -8

No files matched your search

+4 -3
View File
@@ -132,8 +132,9 @@ helpers do
def print_epson_test_page def print_epson_test_page
receipt = ReceiptBuilder.new receipt = ReceiptBuilder.new
receipt.align(:center).bold.size(:big).text("TM-T20II TEST\n").size(:normal).bold(false) receipt.align(:center).bold.size(:big).text("TM-T20II TEST\n").size(:normal).bold(false)
receipt.align(:left).text(('-' * 48) + "\n")
receipt.align(:left).section_separator('TEXT STYLES') receipt.section_separator('TEXT STYLES')
receipt.text("Normal text\n") receipt.text("Normal text\n")
receipt.bold.text("Bold text\n").bold(false) receipt.bold.text("Bold text\n").bold(false)
receipt.underline.text("Underlined text\n").underline(false) receipt.underline.text("Underlined text\n").underline(false)
@@ -150,8 +151,8 @@ helpers do
receipt.section_separator('IMAGE') receipt.section_separator('IMAGE')
receipt.align(:center).image(64, 64, checkerboard_bitmap) receipt.align(:center).image(64, 64, checkerboard_bitmap)
receipt.section_separator receipt.align(:left).text(('-' * 48) + "\n")
receipt.align(:left).text("Printed: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}\n") receipt.text("Printed: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}\n")
receipt.feed(3).cut receipt.feed(3).cut
receipt.print!(PRINTER_DEVICE_EPSON) receipt.print!(PRINTER_DEVICE_EPSON)
end end
+14 -5
View File
@@ -65,17 +65,26 @@ class ReceiptBuilder
self self
end end
# White-on-black reverse video (GS B n) -- the closest this direct-thermal # White-on-black reverse video (GS B n) -- available if a receipt ever
# printer gets to a second "color" for a separator/banner. # wants a real highlight, but plain "=" rules read better for routine
# section breaks than a fully blacked-out line.
def invert(enable = true) def invert(enable = true)
@buffer << (enable ? "\x1D\x42\x01" : "\x1D\x42\x00") @buffer << (enable ? "\x1D\x42\x01" : "\x1D\x42\x00")
self self
end end
# A full-width inverted banner line, e.g. section_separator("SECTION"). # A single "=" rule with an optional label centered in it, e.g.
# section_separator("SECTION") -> "========= SECTION =========".
def section_separator(label = '', width: 48) def section_separator(label = '', width: 48)
padded = label.empty? ? (' ' * width) : " #{label} ".center(width) line = if label.empty?
feed(1).invert.text(padded[0, width]).invert(false).feed(1) '=' * width
else
mid = " #{label} "
pad = [width - mid.length, 0].max
left = pad / 2
('=' * left) + mid + ('=' * (pad - left))
end
feed(1).text("#{line}\n").feed(1)
end end
def size(mode) def size(mode)