changes
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
use libm::include_font;
|
use libm::include_font;
|
||||||
pub static FONT_SPLEEN_8X16: Font =
|
pub static FONT_SPLEEN_8X16: Font =
|
||||||
Font::new(include_font!("./kernel/resources/font/spleen-8x16.psf"));
|
Font::new(include_font!("../../../resources/font/spleen-8x16.psf"));
|
||||||
|
|
||||||
pub static FONT_CP850_8X16: Font =
|
pub static FONT_CP850_8X16: Font =
|
||||||
Font::new(include_font!("./kernel/resources/font/cp850-8x16.psf"));
|
Font::new(include_font!("../../../resources/font/cp850-8x16.psf"));
|
||||||
|
|
||||||
// pub struct Font(pub [[u8; 16]; 512]);
|
// pub struct Font(pub [[u8; 16]; 512]);
|
||||||
|
|
||||||
|
|||||||
+20
-5
@@ -1,3 +1,4 @@
|
|||||||
|
#![feature(proc_macro_span)]
|
||||||
#![warn(
|
#![warn(
|
||||||
clippy::correctness,
|
clippy::correctness,
|
||||||
clippy::nursery,
|
clippy::nursery,
|
||||||
@@ -12,18 +13,32 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Seek, SeekFrom};
|
use std::io::{Read, Seek, SeekFrom};
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::{Span, TokenStream};
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
|
use std::path::PathBuf;
|
||||||
use syn::{LitStr, parse_macro_input};
|
use syn::{LitStr, parse_macro_input};
|
||||||
|
|
||||||
extern crate proc_macro;
|
extern crate proc_macro;
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
|
/// Expects the file path to be relative to the current file so this works
|
||||||
|
/// similarly to the standard Rust include! macros.
|
||||||
pub fn include_font(item: TokenStream) -> TokenStream {
|
pub fn include_font(item: TokenStream) -> TokenStream {
|
||||||
let filename = parse_macro_input!(item as LitStr);
|
let span = Span::call_site();
|
||||||
let file_path = filename.value();
|
let source_file = span.source_file();
|
||||||
|
|
||||||
println!("Loading font: [{}]", file_path);
|
if !source_file.is_real() {
|
||||||
|
panic!(
|
||||||
|
"We can't handle finding files if the source file does not exist. TODO: Can we?"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let filename = parse_macro_input!(item as LitStr);
|
||||||
|
let source_filepath: PathBuf = source_file.path();
|
||||||
|
let file_path = format!(
|
||||||
|
"{}/{}",
|
||||||
|
source_filepath.parent().unwrap_or_else(|| panic!("Expected to find the calling source file in a folder like src! Got: {}", source_filepath.display())).display(),
|
||||||
|
filename.value()
|
||||||
|
);
|
||||||
|
|
||||||
let font_bytes = match load_file(file_path) {
|
let font_bytes = match load_file(file_path) {
|
||||||
Ok(bytes) => bytes,
|
Ok(bytes) => bytes,
|
||||||
|
|||||||
Reference in New Issue
Block a user