| Crates.io | bdf2surface |
| lib.rs | bdf2surface |
| version | 0.0.2 |
| created_at | 2024-08-16 15:29:03.690365+00 |
| updated_at | 2024-08-16 15:59:56.190795+00 |
| description | A crate to convert bdf font to sdl2 surface |
| homepage | |
| repository | https://github.com/locez/bdf2surface |
| max_upload_size | |
| id | 1340416 |
| size | 4,326,777 |
A crate to convert bdf font to sdl2 surface
use sdl2::surface::Surface;
use bdf2surface::{Color, Converter, Text};
let sdl_context = sdl2::init()?;
let _video_subsystem = sdl_context.video()?;
let path = "./resource/wqy_9pt.bdf";
let converter = Converter::new(path);
let texts = vec![
Text("你好,露西!".to_string(), Color::RGB(0, 0, 0)),
Text(
"Hello, ".to_string(),
Color::RGB(255, 0, 0),
),
Text("Locez!".to_string(), Color::RGB(255, 73, 170)),
];
let surface = converter.render(&texts, 60).unwrap();
surface.save_bmp("output.bmp")?;
output.bmp
