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    #[doc(alias = "PangoAnalysis")]
11    pub struct Analysis(BoxedInline<crate::ffi::PangoAnalysis>);
12}
13
14impl Analysis {
15    #[inline]
16    pub fn font(&self) -> Font {
17        unsafe { from_glib_none(self.inner.font) }
18    }
19
20    #[inline]
21    pub fn level(&self) -> u8 {
22        self.inner.level
23    }
24
25    #[inline]
26    pub fn gravity(&self) -> Gravity {
27        unsafe { from_glib(self.inner.gravity as i32) }
28    }
29
30    #[inline]
31    pub fn flags(&self) -> u8 {
32        self.inner.flags
33    }
34
35    #[inline]
36    pub fn script(&self) -> Script {
37        unsafe { from_glib(self.inner.script as i32) }
38    }
39
40    #[inline]
41    pub fn language(&self) -> Language {
42        unsafe { from_glib_none(self.inner.language) }
43    }
44
45    pub fn extra_attrs(&self) -> Vec<Attribute> {
46        unsafe { FromGlibPtrContainer::from_glib_none(self.inner.extra_attrs) }
47    }
48}
49
50impl fmt::Debug for Analysis {
51    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52        f.debug_struct("Analysis")
53            .field("font", &self.font())
54            .field("level", &self.level())
55            .field("gravity", &self.gravity())
56            .field("flags", &self.flags())
57            .field("script", &self.script())
58            .field("extra_attrs", &self.extra_attrs())
59            .finish()
60    }
61}