hiero_pack/atlas/
info.rs

1use super::*; 
2
3#[derive(Serialize, Deserialize, Default)]
4pub struct HieroInfo {
5    pub face: String,
6    pub size: i32,
7    pub bold: i32,
8    pub italic: i32,
9    pub char_set: String,
10    pub unicode: i32,
11    pub stretch_h: i32,
12    pub smooth: i32,
13    pub aa: i32,
14    pub padding: Vec<i32>,
15    pub spacing: Vec<i32>,
16}
17
18
19#[derive(Serialize, Deserialize, Default, Copy, Clone)]
20pub struct PageInfo {
21    pub width: u32,
22    pub height: u32,
23    pub samples: u32, // RGB(samples = 3) or RGBA(samples =4)
24    pub line_size: u32,
25}
26
27
28/// This struct is pretty much just a header, for a sub-image inside the page\
29/// To get actual pixel data for the bitmap, just look up the page and read the sub-image at top left (x,y) , borrown-right:(x+width,y+height)
30#[derive(Serialize, Deserialize, Default, Copy, Clone)]
31pub struct HieroBitmapInfo {
32    pub x: i32,
33    pub y: i32,
34    pub width: i32,
35    pub height: i32,
36    pub xoffset: i32,
37    pub yoffset: i32,
38    pub xadvance: i32,
39    pub page: i32,
40    pub channel: i32,
41}
42impl std::fmt::Display for HieroBitmapInfo {
43    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44        write!(
45            f,
46            "[x:{},y:{},w:{},h:{},xoff:{},yoff:{},xadv:{},pg_num:{},channel:{}]",
47            self.x,
48            self.y,
49            self.width,
50            self.height,
51            self.xoffset,
52            self.yoffset,
53            self.xadvance,
54            self.page,
55            self.channel,
56        )?;
57        Ok(())
58    }
59}