| Crates.io | fontsdf |
| lib.rs | fontsdf |
| version | 0.5.1 |
| created_at | 2022-05-08 19:16:22.292175+00 |
| updated_at | 2023-04-21 15:56:26.6189+00 |
| description | fontdue extension to generate sdf:s directly |
| homepage | |
| repository | https://github.com/Overpeek/fontsdf |
| max_upload_size | |
| id | 582673 |
| size | 281,125 |
Signed Distance Field (SDF) textures can be used to render text or other vector art more flexibly[1], with higher quality while using less video memory (for the texture).
This no_std library renders SDF:s directly and not by downscaling a higher resolution rasters.
[1] For example:
| Task | SDF | regular |
|---|---|---|
| High resolution glyphs | ✓ | ✓ |
| Medium resolution glyphs | ✓ | ✓ |
| Low resolution glyphs | ✓ | |
| Stretched or squished glyphs | ✓ | |
| Shadows borders and effects | ✓ | |
| GUI:s | ✓ | |
| 3D game worlds | ✓ |
image:let font = fontsdf::Font::from_bytes(..).unwrap();
let (metrics, sdf) = font.rasterize('x', 64.0, true);
image::GrayImage::from_raw(metrics.width as _, metrics.height as _, sdf)
.unwrap()
.save("sdf_x.png")
.unwrap();