fontsdf
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:
- It is possible to use single a 64px glyph to render both 14px and 200px glyphs.
- It is easy to add glow, outlines and such.
Comparisons:
NOTE: Use fontdue for simple glyphs instead. It is ~75 times faster.
| Task | SDF | regular |
|---|---|---|
| High resolution glyphs | :white_check_mark: | :white_check_mark: |
| Medium resolution glyphs | :white_check_mark: | :white_check_mark: |
| Low resolution glyphs | :white_check_mark: | |
| Flexible resolution glyphs | :white_check_mark: | |
| Distorted text | :white_check_mark: | |
| Shadows borders and effects | :white_check_mark: | |
| GUI:s | :white_check_mark: | |
| 3D game worlds | :white_check_mark: |
- :white_check_mark: means it is good at
Example usage with image:
let font = from_bytes.unwrap;
let = font.rasterize;
from_raw
.unwrap
.save
.unwrap;
Example output:
Normal
SDF
Example results:
Normal
- 128x156
- 80px font size
SDF
- 128x128
- 48px (+radius) font size (32px input size should be enough for any output size)
- 'free' shadow