pango/
glyph_info.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::fmt;
4
5use crate::GlyphGeometry;
6
7glib::wrapper! {
8    /// A [`GlyphInfo`][crate::GlyphInfo] structure represents a single glyph with
9    /// positioning information and visual attributes.
10    #[doc(alias = "PangoGlyphInfo")]
11    pub struct GlyphInfo(BoxedInline<crate::ffi::PangoGlyphInfo>);
12}
13
14impl GlyphInfo {
15    #[inline]
16    pub fn glyph(&self) -> u32 {
17        self.inner.glyph
18    }
19
20    #[inline]
21    pub fn set_glyph(&mut self, glyph: u32) {
22        self.inner.glyph = glyph
23    }
24
25    #[inline]
26    pub fn geometry(&self) -> &GlyphGeometry {
27        unsafe { &*(&self.inner.geometry as *const _ as *const GlyphGeometry) }
28    }
29
30    #[inline]
31    pub fn geometry_mut(&mut self) -> &mut GlyphGeometry {
32        unsafe { &mut *(&mut self.inner.geometry as *mut _ as *mut GlyphGeometry) }
33    }
34}
35
36impl fmt::Debug for GlyphInfo {
37    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
38        f.debug_struct("GlyphInfo")
39            .field("glyph", &self.glyph())
40            .field("geometry", &self.geometry())
41            .finish()
42    }
43}