parent
289c318804
commit
624a56cc97
2 changed files with 30 additions and 6 deletions
@ -1,14 +1,35 @@ |
|||||||
use std::fs; |
use std::{fs::{self, File}, path::Path, io::Read}; |
||||||
|
|
||||||
struct TypeFace { |
type Character = [[bool; 8]; 14]; |
||||||
type_char: [[bool; 8]; 14], |
|
||||||
|
fn read_file(mut file_name: String) -> Vec<u8> { |
||||||
|
file_name = file_name.replace("/", ""); |
||||||
|
if file_name.is_empty() { |
||||||
|
file_name = String::from("index.html"); |
||||||
|
} |
||||||
|
|
||||||
|
let path = Path::new(&file_name); |
||||||
|
if !path.exists() { |
||||||
|
return String::from("Not Found!").into(); |
||||||
|
} |
||||||
|
let mut file_content = Vec::new(); |
||||||
|
let mut file = File::open(&file_name).expect("Unable to open file"); |
||||||
|
file.read_to_end(&mut file_content).expect("Unable to read"); |
||||||
|
file_content |
||||||
} |
} |
||||||
|
|
||||||
fn get_font() { |
pub fn get_font() { |
||||||
|
// Retrieve font data from file
|
||||||
let file_path = "./fonts/Terminus14x8.data"; |
let file_path = "./fonts/Terminus14x8.data"; |
||||||
|
|
||||||
println!("In file {}", file_path); |
println!("In file {}", file_path); |
||||||
|
|
||||||
let contents = fs::read_to_string(file_path) |
let contents = fs::read_to_string(file_path) |
||||||
.expect("File could not be read"); |
.expect("File could not be read"); |
||||||
|
let width_left_byte = &contents[0..0]; |
||||||
|
let width_right_byte = &contents[1..1]; |
||||||
|
let number_left = width_left_byte.chars().nth(0).unwrap(); |
||||||
|
let number_right = width_right_byte.chars().nth(0).unwrap(); |
||||||
|
let number = [number_left as u8, number_right as u8]; |
||||||
|
let width = i16::from_ne_bytes(number); |
||||||
|
|
||||||
|
println!("{width}") |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue