pango/attr_size.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};
6
7define_attribute_struct!(
8 AttrSize,
9 ffi::PangoAttrSize,
10 &[AttrType::Size, AttrType::AbsoluteSize]
11);
12
13impl AttrSize {
14 /// Create a new font-size attribute in fractional points.
15 /// ## `size`
16 /// the font size, in `PANGO_SCALE`-ths of a point
17 ///
18 /// # Returns
19 ///
20 /// the newly allocated
21 /// [`Attribute`][crate::Attribute], which should be freed with
22 /// `Pango::Attribute::destroy()`
23 #[doc(alias = "pango_attr_size_new")]
24 pub fn new(size: i32) -> Self {
25 unsafe { from_glib_full(ffi::pango_attr_size_new(size)) }
26 }
27
28 #[doc(alias = "pango_attr_size_new_absolute")]
29 pub fn new_size_absolute(size: i32) -> Self {
30 unsafe { from_glib_full(ffi::pango_attr_size_new_absolute(size)) }
31 }
32
33 pub fn size(&self) -> i32 {
34 self.inner.size
35 }
36
37 pub fn absolute(&self) -> bool {
38 unsafe { from_glib(self.inner.absolute as i32) }
39 }
40}