#font #bitmap-font #parser #bmfont #bitmap #sfl

bmfont_parser

Lightweight and easy-to-use bitmap font parser (.sfl and .fnt files)

3 unstable releases

0.2.0 Jan 16, 2019
0.1.1 Jan 16, 2019
0.1.0 Jan 15, 2019

#2629 in Parser implementations

Download history 8/week @ 2024-02-18 7/week @ 2024-02-25 1/week @ 2024-03-03 4/week @ 2024-03-10 1/week @ 2024-03-17 3/week @ 2024-03-24 49/week @ 2024-03-31 1/week @ 2024-04-07

53 downloads per month
Used in glerminal

MIT license

37KB
889 lines

bmfont_parser

Build Status Docs Crates.io

A lightweight and easy-to-use .sfl and .fnt file (bitmap font) parser made with Rust.

Test fonts are generated with Fontbuilder

How to use

Documentation at docs.rs or simply:

  1. Add the following to your dependencies:
    [dependencies]
    bmfont_parser="0.2"
    
  2. To your Rust project add the following line:
    extern crate bmfont_parser;
    
  3. You're done! Here is an example of how to use it:
     use bmfont_parser::{BMFont, Format};
    
     let bmfont = match BMFont::from_path(Format::SFL, "examples/fonts/iosevka.sfl") {
         Ok(bmfont) => bmfont,
         Err(_) => panic!("Failed to load iosevka.sfl"),
     };
    
     println!("bmfont: {}", bmfont);
    
     // Or Alternatively
    
     let iosevka_sfl = include_str!("examples/fonts/iosevka.sfl");
    
     let bmfont = match BMFont::from_loaded(Format::SFL, iosevka_sfl, "examples/fonts/iosevka.sfl") {
         Ok(bmfont) => bmfont,
         Err(_) => panic!("Failed to load iosevka.sfl"),
     };
    
     println!("bmfont: {}", bmfont);
    

License

This crate is distributed under the terms of the MIT License.

No runtime deps