pango/glyph_item.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, GlyphItem, GlyphString, Item};
6
7impl GlyphItem {
8 pub fn item(&self) -> Item {
9 unsafe { from_glib_none((*self.as_ptr()).item) }
10 }
11
12 pub fn glyph_string(&self) -> GlyphString {
13 unsafe { from_glib_none((*self.as_ptr()).glyphs) }
14 }
15
16 #[doc(alias = "pango_glyph_item_get_logical_widths")]
17 #[doc(alias = "get_logical_widths")]
18 pub fn logical_widths(&self, text: &str) -> Vec<i32> {
19 let count = text.chars().count();
20 unsafe {
21 let mut logical_widths = Vec::with_capacity(count);
22 ffi::pango_glyph_item_get_logical_widths(
23 mut_override(self.to_glib_none().0),
24 text.to_glib_none().0,
25 logical_widths.as_mut_ptr(),
26 );
27 logical_widths.set_len(count);
28 logical_widths
29 }
30 }
31}