Test page: replace inverted section banners with plain '=' rules, frame page with '-'
deploy / deploy (push) Successful in 10s
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:
1 parent
a58d4b66ea
commit
4308850a2e
2 files changed
+18
-8
No files matched your search
@@ -132,8 +132,9 @@ helpers do
|
||||
def print_epson_test_page
|
||||
receipt = ReceiptBuilder.new
|
||||
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.bold.text("Bold text\n").bold(false)
|
||||
receipt.underline.text("Underlined text\n").underline(false)
|
||||
@@ -150,8 +151,8 @@ helpers do
|
||||
receipt.section_separator('IMAGE')
|
||||
receipt.align(:center).image(64, 64, checkerboard_bitmap)
|
||||
|
||||
receipt.section_separator
|
||||
receipt.align(:left).text("Printed: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}\n")
|
||||
receipt.align(:left).text(('-' * 48) + "\n")
|
||||
receipt.text("Printed: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}\n")
|
||||
receipt.feed(3).cut
|
||||
receipt.print!(PRINTER_DEVICE_EPSON)
|
||||
end
|
||||
|
||||
+14
-5
@@ -65,17 +65,26 @@ class ReceiptBuilder
|
||||
self
|
||||
end
|
||||
|
||||
# White-on-black reverse video (GS B n) -- the closest this direct-thermal
|
||||
# printer gets to a second "color" for a separator/banner.
|
||||
# White-on-black reverse video (GS B n) -- available if a receipt ever
|
||||
# wants a real highlight, but plain "=" rules read better for routine
|
||||
# section breaks than a fully blacked-out line.
|
||||
def invert(enable = true)
|
||||
@buffer << (enable ? "\x1D\x42\x01" : "\x1D\x42\x00")
|
||||
self
|
||||
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)
|
||||
padded = label.empty? ? (' ' * width) : " #{label} ".center(width)
|
||||
feed(1).invert.text(padded[0, width]).invert(false).feed(1)
|
||||
line = if label.empty?
|
||||
'=' * 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
|
||||
|
||||
def size(mode)
|
||||
|
||||
Reference in new issue
Block a user