#surface #sdl2 #font #convert #color #converter #bdf

bdf2surface

一个将bdf字体转换为sdl2表面的crate

2个版本

0.0.2 2024年8月16日
0.0.1 2024年8月16日

#211 in 图形API

Download history 182/week @ 2024-08-16

182 每月下载量

MIT 许可证

675KB
100 代码行

bdf2surface

一个将bdf字体转换为sdl2表面的crate

示例

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

output.bmp

依赖项

~17MB
~367K SLoC