| Crates.io | glyphr-macros |
| lib.rs | glyphr-macros |
| version | 0.1.2 |
| created_at | 2025-06-13 23:35:26.600481+00 |
| updated_at | 2025-09-09 11:34:04.27028+00 |
| description | Set of proc-macros used to generate fonts for glyphr |
| homepage | |
| repository | https://github.com/Bridiro/glyphr |
| max_upload_size | |
| id | 1711978 |
| size | 73,676 |
This crate contains proc-macros used to generate code at compile time easily. glyphr is an indirect dependency of this crate, as it generates types that are present only there.
glyphr_macros::generate_font! {
name: POPPINS,
path: "fonts/Poppins-Regular.ttf",
size: 64,
characters: "A-Za-z0-9 !$£%&",
format: SDF {
spread: 20.0,
padding: 0,
},
}
glyphr_macros::generate_font_from_toml!("fonts/fonts.toml");
with the toml looking like this:
[[font]]
name = "POPPINS"
path = "Poppins-Regular.ttf"
size = 64
characters = "A-Za-z0-9 !$£%&"
format = { SDF = { spread = 20.0, padding = 0}}
The TOML functionality is behind a feature called toml that is enabled by default in glyphr itself.
Format can either be SDF or Bitmap.
SDF is the prettier format, as it enables the user to resize the generated code at runtime. As resizing and calculating positions require computation, it's suggested to use this option for text that needs to be pretty, but at the same time not with the fastest refresh rate (only if you're on an MCU or similar).
This is the fast and memory efficient way. Font generated this way can't be rescaled at runtime, but it's generally 8x smaller than an SDF generated font. This means that if you only need from 1 to 4 sizes, you can use this to save space.