pango/auto/glyph_item.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{AttrList, ffi};
6use glib::translate::*;
7
8glib::wrapper! {
9 /// A [`GlyphItem`][crate::GlyphItem] is a pair of a [`Item`][crate::Item] and the glyphs
10 /// resulting from shaping the items text.
11 ///
12 /// As an example of the usage of [`GlyphItem`][crate::GlyphItem], the results
13 /// of shaping text with [`Layout`][crate::Layout] is a list of [`LayoutLine`][crate::LayoutLine],
14 /// each of which contains a list of [`GlyphItem`][crate::GlyphItem].
15 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
16 pub struct GlyphItem(Boxed<ffi::PangoGlyphItem>);
17
18 match fn {
19 copy => |ptr| ffi::pango_glyph_item_copy(mut_override(ptr)),
20 free => |ptr| ffi::pango_glyph_item_free(ptr),
21 type_ => || ffi::pango_glyph_item_get_type(),
22 }
23}
24
25impl GlyphItem {
26 /// extra_attrs for some of the
27 /// result items can have multiple attributes of the same type.
28 ///
29 /// This function takes ownership of @self; it will be reused
30 /// as one of the elements in the list.
31 /// ## `text`
32 /// text that @list applies to
33 /// ## `list`
34 /// a [`AttrList`][crate::AttrList]
35 ///
36 /// # Returns
37 ///
38 /// a
39 /// list of glyph items resulting from splitting @self. Free
40 /// the elements using `Pango::GlyphItem::free()`, the list using
41 /// g_slist_free().
42 #[doc(alias = "pango_glyph_item_apply_attrs")]
43 pub fn apply_attrs(self, text: &str, list: &AttrList) -> Vec<GlyphItem> {
44 unsafe {
45 FromGlibPtrContainer::from_glib_full(ffi::pango_glyph_item_apply_attrs(
46 self.into_glib_ptr(),
47 text.to_glib_none().0,
48 list.to_glib_none().0,
49 ))
50 }
51 }
52
53 //#[doc(alias = "pango_glyph_item_letter_space")]
54 //pub fn letter_space(&mut self, text: &str, log_attrs: /*Ignored*/&[LogAttr], letter_spacing: i32) {
55 // unsafe { TODO: call ffi:pango_glyph_item_letter_space() }
56 //}
57
58 /// Modifies @self to cover only the text after @split_index, and
59 /// returns a new item that covers the text before @split_index that
60 /// used to be in @self.
61 ///
62 /// You can think of @split_index as the length of the returned item.
63 /// @split_index may not be 0, and it may not be greater than or equal
64 /// to the length of @self (that is, there must be at least one byte
65 /// assigned to each item, you can't create a zero-length item).
66 ///
67 /// This function is similar in function to pango_item_split() (and uses
68 /// it internally.)
69 /// ## `text`
70 /// text to which positions in @self apply
71 /// ## `split_index`
72 /// byte index of position to split item, relative to the
73 /// start of the item
74 ///
75 /// # Returns
76 ///
77 /// the newly allocated item
78 /// representing text before @split_index, which should be freed
79 /// with pango_glyph_item_free().
80 #[doc(alias = "pango_glyph_item_split")]
81 #[must_use]
82 pub fn split(&mut self, text: &str, split_index: i32) -> Option<GlyphItem> {
83 unsafe {
84 from_glib_full(ffi::pango_glyph_item_split(
85 self.to_glib_none_mut().0,
86 text.to_glib_none().0,
87 split_index,
88 ))
89 }
90 }
91}