Skip to main content

ql_label/
lib.rs

1//! P-Touch Printer Driver
2//!
3//! This crate provides a printer driver for Brother P-Touch QL series label printers.
4//!
5//! # Example
6//!
7//! ```rust,no_run
8//! use ptouch::{Config, ContinuousType, Media, Model, Printer};
9//! 
10//! let media = Media::Continuous(ContinuousType::Continuous29);
11//! let model = Model::QL820NWB;
12//! let config = Config::new(model, "serial".to_string(), media);
13//! let printer = Printer::new(config).unwrap();
14//! ```
15
16mod error;
17mod media;
18mod model;
19mod printer;
20mod utils;
21
22pub use crate::{
23    error::{Error, PrinterError},
24    media::{ContinuousType, DieCutType, Media},
25    model::Model,
26    printer::{Config, Printer, Status},
27    utils::{convert_rgb_to_two_color, step_filter_normal, step_filter_wide, TwoColorMatrix},
28};
29
30/// Type alias for 1-bit bitmap data used by printers.
31///
32/// Each inner `Vec<u8>` represents a single row of pixels, with 8 pixels
33/// packed into each byte. The outer Vec represents multiple rows.
34/// 
35/// For normal printers: each row should be 90 bytes (720 pixels / 8)
36/// For wide printers: each row should be 162 bytes (1296 pixels / 8)
37pub type Matrix = Vec<Vec<u8>>;
38
39/// Width in pixels for normal P-Touch printers (QL-720NW, QL-800, QL-820NWB).
40///
41/// Normal printers use 720 pixels across the tape width, requiring
42/// 90 bytes per row when packed into bitmap format (720 / 8 = 90).
43pub const NORMAL_PRINTER_WIDTH: u32 = 720;
44
45/// Width in pixels for wide P-Touch printers (QL-1100 series).
46///
47/// Wide printers use 1296 pixels across the tape width, requiring
48/// 162 bytes per row when packed into bitmap format (1296 / 8 = 162).
49pub const WIDE_PRINTER_WIDTH: u32 = 1296;