pango/
attr_font_desc.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, AttrType, FontDescription};
6
7define_attribute_struct!(AttrFontDesc, ffi::PangoAttrFontDesc, &[AttrType::FontDesc]);
8
9impl AttrFontDesc {
10    /// Create a new font description attribute.
11    ///
12    /// This attribute allows setting family, style, weight, variant,
13    /// stretch, and size simultaneously.
14    /// ## `desc`
15    /// the font description
16    ///
17    /// # Returns
18    ///
19    /// the newly allocated
20    ///   [`Attribute`][crate::Attribute], which should be freed with
21    ///   `Pango::Attribute::destroy()`
22    #[doc(alias = "pango_attr_font_desc_new")]
23    pub fn new(desc: &FontDescription) -> Self {
24        unsafe { from_glib_full(ffi::pango_attr_font_desc_new(desc.to_glib_none().0)) }
25    }
26
27    pub fn desc(&self) -> FontDescription {
28        unsafe { from_glib_none(self.inner.desc) }
29    }
30}