| Crates.io | font-map |
| lib.rs | font-map |
| version | 0.2.9 |
| created_at | 2025-01-29 20:00:07.909326+00 |
| updated_at | 2025-03-25 00:33:31.279688+00 |
| description | Macros and utilities for parsing font files |
| homepage | |
| repository | https://github.com/rscarson/font-map |
| max_upload_size | |
| id | 1535274 |
| size | 39,711 |
This crate provides functionality for parsing font files and enumerating the glyphs they contain.
The base usecase for this crate is to create an enum of all the glyphs in a font file,
for use in fontend projects, where you want to refer to glyphs by name rather than by codepoint:
use font_map::font;
font!(Icon, "google_material_symbols/font.ttf");
const DELETE: Icon = Icon::Delete;
The generated code includes information for each glyph, such as:
You can also access Icon::FONT_FAMILY to simplify font usage in your frontend.
Another use is to use it for introspection of font files:
use font_map::font::Font;
let font = Font::from_file("google_material_symbols/font.ttf")?;
if let Some(glyph) = font.glyph_named("delete") {
let codepoint = glyph.codepoint();
let svg = glyph.svg_preview();
}
macros - Enables the font! macro for code generationcodegen - Enables the FontCodegenExt trait for runtime code generationextended-svg - Enables compressed and base64 encoded SVG data in the generated code (Needed for image previews)This crate was made for a very specific use-case, and as such currently has a few limitations:
cmap tableMacintosh::0 of the name tablepost table