font-map
Font parser / enumerator with support for code generation
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;
font!;
const DELETE: Icon = Delete;
The generated code includes information for each glyph, such as:
- codepoint, and postfix-name
- Plus a generated SVG preview image visible on hover
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;
let font = from_file?;
if let Some = font.glyph_named
Features
macros- Enables thefont!macro for code generationcodegen- Enables theFontCodegenExttrait for runtime code generationextended-svg- Enables compressed and base64 encoded SVG data in the generated code (Needed for image previews)
Known Limitations
This crate was made for a very specific use-case, and as such currently has a few limitations:
- Only supports TTF fonts
- And even then, only a subset of the spec, namely:
- Only some formats of the
cmaptable - Only Unicode, or MS encoding 1 and 10, and
Macintosh::0of thenametable - Only formats 2.5 or below of the
posttable