kiss3d/text/
glyph.rs

1// This whole file is strongly inspired by: https://github.com/jeaye/q3/blob/master/src/client/ui/ttf/glyph.rs
2// available under the BSD-3 licence.
3// It has been modified to work with gl-rs, nalgebra, and rust-freetype
4
5use na::Vector2;
6
7/// A ttf glyph.
8pub struct Glyph {
9    #[doc(hidden)]
10    pub tex: Vector2<f32>,
11    #[doc(hidden)]
12    pub advance: Vector2<f32>,
13    #[doc(hidden)]
14    pub dimensions: Vector2<f32>,
15    #[doc(hidden)]
16    pub offset: Vector2<f32>,
17    #[doc(hidden)]
18    pub buffer: Vec<u8>,
19}
20
21impl Glyph {
22    /// Creates a new empty glyph.
23    pub fn new(
24        tex: Vector2<f32>,
25        advance: Vector2<f32>,
26        dimensions: Vector2<f32>,
27        offset: Vector2<f32>,
28        buffer: Vec<u8>,
29    ) -> Glyph {
30        Glyph {
31            tex,
32            advance,
33            dimensions,
34            offset,
35            buffer,
36        }
37    }
38}