A novel library for converting glyphs into triangulations which can be used when rendering text in Game and Application interfaces.
```rust use vdtfont::{, delaunay::};
// Create a font let fontdata = includebytes!("/usr/share/fonts/truetype/open-sans/OpenSans-Regular.ttf"); let mut font = Font::fromvec(fontdata.to_vec())?;
// Obtain a glyph let glyph = font.glyph('a'); // Outline the glyph let outlinedglyph = font.outlineglyph(glyph); // Triangulate th glyph let triangulatedglyph = font.triangulateglyph(outlined_glyph)?;
// Use the resulting triangulation
triangulatedglyph
.triangles()
.handleiter::
Full documentaion: https://docs.rs/vdtfont
VDTFont uses OpenCL to build Voronoi diagram and compute Delaunay triangulation with points from the glyph. The triangulation of the glyph can be used for its rendering.
Full algorithm of triangulation is described in the paper "Computing Two-dimensional Delaunay Triangulation Using Graphics Hardware".
The original font_rasterizer wasn't competetive so it was decided to almost fully rewrite it.
A new library VDTFont doesn't use classical method of rasterizing every pixel, but triangulates glyphs using GPU.
On Debian 11: * ocl-icd-libopencl1 * opencl-headers * OpenCL drivers for your GPU (e.g. intel-opencl-icd for Intel GPU)
Run the following Cargo command in your Rust project directory:
bash
$ cargo add vdtfont
Or add the following line to your Cargo.toml:
vdtfont = "0.3.2"
Run the following Cargo command in the project directory:
bash
$ cargo build --release
Run the following command:
```bash
$ cargo build --release --example simple
$ ./target/release/examples/simple Enter any symbol (CTRL + C to exit): r The image of the symbol was saved in r.png ```