pango/auto/
fontset.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::{ffi, Font, FontMetrics};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    #[doc(alias = "PangoFontset")]
10    pub struct Fontset(Object<ffi::PangoFontset, ffi::PangoFontsetClass>);
11
12    match fn {
13        type_ => || ffi::pango_fontset_get_type(),
14    }
15}
16
17impl Fontset {
18    pub const NONE: Option<&'static Fontset> = None;
19}
20
21pub trait FontsetExt: IsA<Fontset> + 'static {
22    #[doc(alias = "pango_fontset_foreach")]
23    fn foreach<P: FnMut(&Fontset, &Font) -> bool>(&self, func: P) {
24        let mut func_data: P = func;
25        unsafe extern "C" fn func_func<P: FnMut(&Fontset, &Font) -> bool>(
26            fontset: *mut ffi::PangoFontset,
27            font: *mut ffi::PangoFont,
28            user_data: glib::ffi::gpointer,
29        ) -> glib::ffi::gboolean {
30            let fontset = from_glib_borrow(fontset);
31            let font = from_glib_borrow(font);
32            let callback = user_data as *mut P;
33            (*callback)(&fontset, &font).into_glib()
34        }
35        let func = Some(func_func::<P> as _);
36        let super_callback0: &mut P = &mut func_data;
37        unsafe {
38            ffi::pango_fontset_foreach(
39                self.as_ref().to_glib_none().0,
40                func,
41                super_callback0 as *mut _ as *mut _,
42            );
43        }
44    }
45
46    #[doc(alias = "pango_fontset_get_font")]
47    #[doc(alias = "get_font")]
48    fn font(&self, wc: u32) -> Font {
49        unsafe {
50            from_glib_full(ffi::pango_fontset_get_font(
51                self.as_ref().to_glib_none().0,
52                wc,
53            ))
54        }
55    }
56
57    #[doc(alias = "pango_fontset_get_metrics")]
58    #[doc(alias = "get_metrics")]
59    fn metrics(&self) -> FontMetrics {
60        unsafe {
61            from_glib_full(ffi::pango_fontset_get_metrics(
62                self.as_ref().to_glib_none().0,
63            ))
64        }
65    }
66}
67
68impl<O: IsA<Fontset>> FontsetExt for O {}