pango/
analysis.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::fmt;
4
5use glib::translate::*;
6
7use crate::{Attribute, Font, Gravity, Language, Script};
8
9glib::wrapper! {
10    /// The [`Analysis`][crate::Analysis] structure stores information about
11    /// the properties of a segment of text.
12    #[doc(alias = "PangoAnalysis")]
13    pub struct Analysis(BoxedInline<crate::ffi::PangoAnalysis>);
14}
15
16impl Analysis {
17    #[inline]
18    pub fn font(&self) -> Font {
19        unsafe { from_glib_none(self.inner.font) }
20    }
21
22    #[inline]
23    pub fn level(&self) -> u8 {
24        self.inner.level
25    }
26
27    #[inline]
28    pub fn gravity(&self) -> Gravity {
29        unsafe { from_glib(self.inner.gravity as i32) }
30    }
31
32    #[inline]
33    pub fn flags(&self) -> u8 {
34        self.inner.flags
35    }
36
37    #[inline]
38    pub fn script(&self) -> Script {
39        unsafe { from_glib(self.inner.script as i32) }
40    }
41
42    #[inline]
43    pub fn language(&self) -> Language {
44        unsafe { from_glib_none(self.inner.language) }
45    }
46
47    pub fn extra_attrs(&self) -> Vec<Attribute> {
48        unsafe { FromGlibPtrContainer::from_glib_none(self.inner.extra_attrs) }
49    }
50}
51
52impl fmt::Debug for Analysis {
53    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54        f.debug_struct("Analysis")
55            .field("font", &self.font())
56            .field("level", &self.level())
57            .field("gravity", &self.gravity())
58            .field("flags", &self.flags())
59            .field("script", &self.script())
60            .field("extra_attrs", &self.extra_attrs())
61            .finish()
62    }
63}