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
21mod sealed {
22    pub trait Sealed {}
23    impl<T: super::IsA<super::Fontset>> Sealed for T {}
24}
25
26pub trait FontsetExt: IsA<Fontset> + sealed::Sealed + 'static {
27    #[doc(alias = "pango_fontset_foreach")]
28    fn foreach<P: FnMut(&Fontset, &Font) -> bool>(&self, func: P) {
29        let mut func_data: P = func;
30        unsafe extern "C" fn func_func<P: FnMut(&Fontset, &Font) -> bool>(
31            fontset: *mut ffi::PangoFontset,
32            font: *mut ffi::PangoFont,
33            user_data: glib::ffi::gpointer,
34        ) -> glib::ffi::gboolean {
35            let fontset = from_glib_borrow(fontset);
36            let font = from_glib_borrow(font);
37            let callback = user_data as *mut P;
38            (*callback)(&fontset, &font).into_glib()
39        }
40        let func = Some(func_func::<P> as _);
41        let super_callback0: &mut P = &mut func_data;
42        unsafe {
43            ffi::pango_fontset_foreach(
44                self.as_ref().to_glib_none().0,
45                func,
46                super_callback0 as *mut _ as *mut _,
47            );
48        }
49    }
50
51    #[doc(alias = "pango_fontset_get_font")]
52    #[doc(alias = "get_font")]
53    fn font(&self, wc: u32) -> Font {
54        unsafe {
55            from_glib_full(ffi::pango_fontset_get_font(
56                self.as_ref().to_glib_none().0,
57                wc,
58            ))
59        }
60    }
61
62    #[doc(alias = "pango_fontset_get_metrics")]
63    #[doc(alias = "get_metrics")]
64    fn metrics(&self) -> FontMetrics {
65        unsafe {
66            from_glib_full(ffi::pango_fontset_get_metrics(
67                self.as_ref().to_glib_none().0,
68            ))
69        }
70    }
71}
72
73impl<O: IsA<Fontset>> FontsetExt for O {}