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 /// 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 let fontset = from_glib_borrow(fontset);
54 let font = from_glib_borrow(font);
55 let callback = user_data as *mut P;
56 (*callback)(&fontset, &font).into_glib()
57 }
58 let func = Some(func_func::<P> as _);
59 let super_callback0: &mut P = &mut func_data;
60 unsafe {
61 ffi::pango_fontset_foreach(
62 self.as_ref().to_glib_none().0,
63 func,
64 super_callback0 as *mut _ as *mut _,
65 );
66 }
67 }
68
69 /// Returns the font in the fontset that contains the best
70 /// glyph for a Unicode character.
71 /// ## `wc`
72 /// a Unicode character
73 ///
74 /// # Returns
75 ///
76 /// a [`Font`][crate::Font]
77 #[doc(alias = "pango_fontset_get_font")]
78 #[doc(alias = "get_font")]
79 fn font(&self, wc: u32) -> Font {
80 unsafe {
81 from_glib_full(ffi::pango_fontset_get_font(
82 self.as_ref().to_glib_none().0,
83 wc,
84 ))
85 }
86 }
87
88 /// Get overall metric information for the fonts in the fontset.
89 ///
90 /// # Returns
91 ///
92 /// a [`FontMetrics`][crate::FontMetrics] object
93 #[doc(alias = "pango_fontset_get_metrics")]
94 #[doc(alias = "get_metrics")]
95 fn metrics(&self) -> FontMetrics {
96 unsafe {
97 from_glib_full(ffi::pango_fontset_get_metrics(
98 self.as_ref().to_glib_none().0,
99 ))
100 }
101 }
102}
103
104impl<O: IsA<Fontset>> FontsetExt for O {}