sfml/graphics/glyph.rs
1use crate::{
2 ffi,
3 graphics::{FloatRect, IntRect},
4};
5
6/// Structure describing a glyph.
7///
8/// A glyph is the visual representation of a character.
9///
10/// The `Glyph` structure provides the information needed to handle the glyph:
11///
12/// - its coordinates in the font's texture
13/// - its bounding rectangle
14/// - the offset to apply to get the starting position of the next glyph
15#[derive(Clone, Copy, Debug)]
16#[repr(transparent)]
17pub struct Glyph(pub(super) ffi::graphics::sfGlyph);
18
19impl Glyph {
20 /// Offset to move horizontally to the next character.
21 #[must_use]
22 pub fn advance(&self) -> f32 {
23 self.0.advance
24 }
25 /// Bounding rectangle of the glyph, in coordinates relative to the baseline.
26 #[must_use]
27 pub fn bounds(&self) -> FloatRect {
28 self.0.bounds
29 }
30 /// Texture coordinates of the glyph inside the font's texture.
31 #[must_use]
32 pub fn texture_rect(&self) -> IntRect {
33 self.0.texture_rect
34 }
35}