1use binary::from_octets;
7use std::io;
8pub mod binary;
9pub mod text;
10
11use std::collections::HashMap;
12
13#[derive(Debug)]
14pub struct BMFont {
15 pub info: Option<InfoBlock>,
16 pub common: Option<CommonBlock>,
17 pub pages: Vec<String>,
18 pub chars: HashMap<u32, Char>,
19 pub kernings: Vec<KerningPair>,
20}
21
22#[derive(Debug)]
23pub struct InfoBlock {
24 pub font_size: i16,
25 pub bit_field: u8,
26 pub char_set: u8,
27 pub stretch_h: u16,
28 pub aa: u8,
29 pub padding: [u8; 4],
30 pub spacing: [u8; 2],
31 pub outline: u8,
32 pub font_name: String,
33}
34
35#[derive(Debug)]
36pub struct CommonBlock {
37 pub line_height: u16,
38 pub base: u16,
39 pub scale_w: u16,
40 pub scale_h: u16,
41 pub pages: u16,
42 pub bit_field: u8,
43 pub alpha_chnl: u8,
44 pub red_chnl: u8,
45 pub green_chnl: u8,
46 pub blue_chnl: u8,
47}
48
49#[derive(Debug)]
50pub struct Char {
51 pub id: u32,
52 pub x: u16,
53 pub y: u16,
54 pub width: u16,
55 pub height: u16,
56 pub x_offset: i16,
57 pub y_offset: i16,
58 pub x_advance: i16,
59 pub page: u8,
60 pub chnl: u8,
61}
62
63#[derive(Debug)]
64pub struct KerningPair {
65 pub first: u32,
66 pub second: u32,
67 pub amount: i16,
68}
69
70impl BMFont {
71 pub fn from_octets(data: &[u8]) -> io::Result<Self> {
72 from_octets(data)
73 }
74}