This library renders SDF:s directly and not by downscaling a higher resolution rasters. This is probably faster, but my implementation is definitely not fast.
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).
[1] For example:
| Task | SDF | regular | |---------------------------:|:------------------:|:-------------------:| | High resolution glyphs | :whitecheckmark: | :whitecheckmark: | | Medium resolution glyphs | :whitecheckmark: | :whitecheckmark: | | Low resolution glyphs | | :whitecheckmark: | | Flexible resolution glyphs | :whitecheckmark: | | | Distorted text | :whitecheckmark: | | | Shadows borders and effects| :whitecheckmark: | | | GUI:s | | :whitecheckmark: | | 3D game worlds | :whitecheckmark: | |
image
:```rust let font = fontsdf::Font::from_bytes(..).unwrap();
let (metrics, sdf) = font.rasterize('x', 64.0, true); image::GrayImage::fromraw(metrics.width as _, metrics.height as _, sdf) .unwrap() .save("sdfx.png") .unwrap(); ```