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::{Font, FontMetrics, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// A [`Fontset`][crate::Fontset] represents a set of [`Font`][crate::Font] to use when rendering text.
10 ///
11 /// A [`Fontset`][crate::Fontset] is the result of resolving a [`FontDescription`][crate::FontDescription]
12 /// against a particular [`Context`][crate::Context]. It has operations for finding the
13 /// component font for a particular Unicode character, and for finding a
14 /// composite set of metrics for the entire fontset.
15 ///
16 /// This is an Abstract Base Class, you cannot instantiate it.
17 ///
18 /// # Implements
19 ///
20 /// [`FontsetExt`][trait@crate::prelude::FontsetExt]
21 #[doc(alias = "PangoFontset")]
22 pub struct Fontset(Object<ffi::PangoFontset, ffi::PangoFontsetClass>);
23
24 match fn {
25 type_ => || ffi::pango_fontset_get_type(),
26 }
27}
28
29impl Fontset {
30 pub const NONE: Option<&'static Fontset> = None;
31}
32
33/// Trait containing all [`struct@Fontset`] methods.
34///
35/// # Implementors
36///
37/// [`FontsetSimple`][struct@crate::FontsetSimple], [`Fontset`][struct@crate::Fontset]
38pub trait FontsetExt: IsA<Fontset> + 'static {
39 /// Iterates through all the fonts in a fontset, calling @func for
40 /// each one.
41 ///
42 /// If @func returns [`true`], that stops the iteration.
43 /// ## `func`
44 /// Callback function
45 #[doc(alias = "pango_fontset_foreach")]
46 fn foreach<P: FnMut(&Fontset, &Font) -> bool>(&self, func: P) {
47 let mut func_data: P = func;
48 unsafe extern "C" fn func_func<P: FnMut(&Fontset, &Font) -> bool>(
49 fontset: *mut ffi::PangoFontset,
50 font: *mut ffi::PangoFont,
51 user_data: glib::ffi::gpointer,
52 ) -> glib::ffi::gboolean {
53 unsafe {
54 let fontset = from_glib_borrow(fontset);
55 let font = from_glib_borrow(font);
56 let callback = user_data as *mut P;
57 (*callback)(&fontset, &font).into_glib()
58 }
59 }
60 let func = Some(func_func::<P> as _);
61 let super_callback0: &mut P = &mut func_data;
62 unsafe {
63 ffi::pango_fontset_foreach(
64 self.as_ref().to_glib_none().0,
65 func,
66 super_callback0 as *mut _ as *mut _,
67 );
68 }
69 }
70
71 /// Returns the font in the fontset that contains the best
72 /// glyph for a Unicode character.
73 /// ## `wc`
74 /// a Unicode character
75 ///
76 /// # Returns
77 ///
78 /// a [`Font`][crate::Font]
79 #[doc(alias = "pango_fontset_get_font")]
80 #[doc(alias = "get_font")]
81 fn font(&self, wc: u32) -> Font {
82 unsafe {
83 from_glib_full(ffi::pango_fontset_get_font(
84 self.as_ref().to_glib_none().0,
85 wc,
86 ))
87 }
88 }
89
90 /// Get overall metric information for the fonts in the fontset.
91 ///
92 /// # Returns
93 ///
94 /// a [`FontMetrics`][crate::FontMetrics] object
95 #[doc(alias = "pango_fontset_get_metrics")]
96 #[doc(alias = "get_metrics")]
97 fn metrics(&self) -> FontMetrics {
98 unsafe {
99 from_glib_full(ffi::pango_fontset_get_metrics(
100 self.as_ref().to_glib_none().0,
101 ))
102 }
103 }
104}
105
106impl<O: IsA<Fontset>> FontsetExt for O {}