xref: /StarryEngine/starry_client/src/font/unifont.rs (revision 02d6d5e36af6e616feef1951475d2ed219a43e26)
1 #![feature(str_checked_slicing)]
2 
3 use std::fs::File;
4 use std::io::{BufRead, BufReader, Write};
5 
main()6 fn main() {
7     let input = File::open("unifont.hex").unwrap();
8     let mut output = File::create("unifont.font").unwrap();
9 
10     let mut count = 0;
11     for line_res in BufReader::new(input).lines() {
12         let line = line_res.unwrap();
13 
14         let mut parts = line.split(":");
15         let num = u32::from_str_radix(parts.next().unwrap(), 16).unwrap();
16 
17         while count < num {
18             output.write(&[0; 16]).unwrap();
19             count += 1;
20         }
21 
22         assert_eq!(num, count);
23 
24         let mut data = [0; 16];
25         let data_part = parts.next().unwrap();
26         for i in 0..data.len() {
27             let string = data_part.get(i * 2 .. i * 2 + 2).unwrap_or("00");
28             data[i] = u8::from_str_radix(string, 16).unwrap();
29         }
30         println!("{:>04X}:{:?}", num, data);
31 
32         output.write(&data).unwrap();
33         count += 1;
34     }
35 }
36