escpos/protocol
Low-level ESC/POS command encoding.
Each function returns a BitArray containing the raw bytes for a single
ESC/POS command. These are used internally by the escpos module to
build command buffers.
Types
Built-in printer font. Available fonts vary by printer model; FontA and FontB are the most widely supported.
pub type Font {
FontA
FontB
FontC
FontD
FontE
SpecialFontA
SpecialFontB
}
Constructors
-
FontA -
FontB -
FontC -
FontD -
FontE -
SpecialFontA -
SpecialFontB
Image scaling factor for the graphics buffer.
pub type ImageScale {
Scale1x
Scale2x
}
Constructors
-
Scale1x -
Scale2x
Image tone mode. Most printers only support Monochrome.
pub type ImageTone {
Monochrome
MultipleTone
}
Constructors
-
Monochrome -
MultipleTone
Text justification mode.
pub type Justify {
Left
Center
Right
}
Constructors
-
Left -
Center -
Right
Print color selection. Most printers only support Color1 (black).
pub type PrintColor {
Color1
Color2
Color3
Color4
}
Constructors
-
Color1 -
Color2 -
Color3 -
Color4
Values
pub fn character_size(width: Int, height: Int) -> BitArray
Sets character width and height 1–8 (GS !).
pub fn double_strike(on: Bool) -> BitArray
Enables or disables double-strike text (ESC G).
pub fn image_to_graphics_buffer(
data: BitArray,
width: Int,
height: Int,
tone: ImageTone,
scale_x: ImageScale,
scale_y: ImageScale,
color: PrintColor,
) -> BitArray
Stores raster image data into the printer’s graphics buffer
(GS ( L, fn=112).
pub fn justify(justify: Justify) -> BitArray
Sets text justification (ESC a). Must be at the start of a line
to take effect.
pub fn line_feed(lines: Int) -> BitArray
Feeds the given number of lines, clamped to 1–255 (ESC d).
pub fn print_graphics_buffer() -> BitArray
Prints the contents of the graphics buffer (GS ( L, fn=50).
pub fn reverse(on: Bool) -> BitArray
Enables or disables reverse (white on black) printing (GS B).
pub fn upside_down(on: Bool) -> BitArray
Enables or disables upside-down printing (ESC {).