Skip to content

Commit

Permalink
feat(sdl): embed font
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhole committed May 4, 2024
1 parent faa324d commit 998fc40
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 4 deletions.
Binary file added assets/Inconsolata.ttf
Binary file not shown.
1 change: 0 additions & 1 deletion sdl/assets

This file was deleted.

7 changes: 4 additions & 3 deletions sdl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ use sdl2::render::TextureQuery;
// use serde_json;
// use rand::{self, RngCore};

const FONT_DATA: &[u8] = include_bytes!("../../assets/Inconsolata.ttf");

use clap::{App, Arg};

#[derive(Debug)]
Expand Down Expand Up @@ -170,8 +172,6 @@ pub fn main() -> Result<(), FrontError> {
None => vec![],
};

let font_path: &Path = Path::new("./assets/DejaVuSansMono.ttf");

let mut core = Core::new();
load_hex_file(&mut core, path)?;

Expand Down Expand Up @@ -221,7 +221,8 @@ pub fn main() -> Result<(), FrontError> {

let mut canvas = window.into_canvas().build().map_err(|e| e.to_string())?;

let mut font = ttf_context.load_font(font_path, 128)?;
let font_rwops = sdl2::rwops::RWops::from_bytes(FONT_DATA)?;
let mut font = ttf_context.load_font_from_rwops(font_rwops, 128)?;
font.set_style(sdl2::ttf::FontStyle::NORMAL);

canvas.set_draw_color(Color::RGB(0, 0, 0));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 998fc40

Please sign in to comment.