1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
extern crate serde;

use serde::{Serialize, Deserialize};

/// Common fonts used in thermal printers
#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq)]
pub enum Font {
    FontA,
    FontB,
    FontC,
    FontD,
    FontE
}

impl Eq for Font{}

impl Font {
    /// Byte representation of each font.
    pub fn as_bytes(&self) -> Vec<u8> {
        match self {
            Font::FontA => vec![0x00],
            Font::FontB => vec![0x01],
            Font::FontC => vec![0x02],
            Font::FontD => vec![0x03],
            Font::FontE => vec![0x04]
        }
    }
}