pango/attr_shape.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, Rectangle};
6
7define_attribute_struct!(AttrShape, ffi::PangoAttrShape, &[AttrType::Shape]);
8
9impl AttrShape {
10 /// Create a new shape attribute.
11 ///
12 /// A shape is used to impose a particular ink and logical
13 /// rectangle on the result of shaping a particular glyph.
14 /// This might be used, for instance, for embedding a picture
15 /// or a widget inside a [`Layout`][crate::Layout].
16 /// ## `ink_rect`
17 /// ink rectangle to assign to each character
18 /// ## `logical_rect`
19 /// logical rectangle to assign to each character
20 ///
21 /// # Returns
22 ///
23 /// the newly allocated
24 /// [`Attribute`][crate::Attribute], which should be freed with
25 /// `Pango::Attribute::destroy()`
26 #[doc(alias = "pango_attr_shape_new")]
27 pub fn new(ink_rect: &Rectangle, logical_rect: &Rectangle) -> Self {
28 unsafe {
29 from_glib_full(ffi::pango_attr_shape_new(
30 ink_rect.to_glib_none().0,
31 logical_rect.to_glib_none().0,
32 ))
33 }
34 }
35
36 pub fn ink_rect(&self) -> Rectangle {
37 unsafe { from_glib_none(&self.inner.ink_rect as *const _) }
38 }
39
40 pub fn logical_rect(&self) -> Rectangle {
41 unsafe { from_glib_none(&self.inner.logical_rect as *const _) }
42 }
43}