escpos_rust/command/
font.rs

1extern crate serde;
2
3use serde::{Serialize, Deserialize};
4
5/// Common fonts used in thermal printers
6#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq)]
7pub enum Font {
8    FontA,
9    FontB,
10    FontC,
11    FontD,
12    FontE
13}
14
15impl Eq for Font{}
16
17impl Font {
18    /// Byte representation of each font.
19    pub fn as_bytes(&self) -> Vec<u8> {
20        match self {
21            Font::FontA => vec![0x00],
22            Font::FontB => vec![0x01],
23            Font::FontC => vec![0x02],
24            Font::FontD => vec![0x03],
25            Font::FontE => vec![0x04]
26        }
27    }
28}