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
33mod sealed {
34 pub trait Sealed {}
35 impl<T: super::IsA<super::Fontset>> Sealed for T {}
36}
37
38/// Trait containing all [`struct@Fontset`] methods.
39///
40/// # Implementors
41///
42/// [`FontsetSimple`][struct@crate::FontsetSimple], [`Fontset`][struct@crate::Fontset]
43pub trait FontsetExt: IsA<Fontset> + sealed::Sealed + 'static {
44 /// Iterates through all the fonts in a fontset, calling @func for
45 /// each one.
46 ///
47 /// If @func returns [`true`], that stops the iteration.
48 /// ## `func`
49 /// Callback function
50 #[doc(alias = "pango_fontset_foreach")]
51 fn foreach<P: FnMut(&Fontset, &Font) -> bool>(&self, func: P) {
52 let mut func_data: P = func;
53 unsafe extern "C" fn func_func<P: FnMut(&Fontset, &Font) -> bool>(
54 fontset: *mut ffi::PangoFontset,
55 font: *mut ffi::PangoFont,
56 user_data: glib::ffi::gpointer,
57 ) -> glib::ffi::gboolean {
58 let fontset = from_glib_borrow(fontset);
59 let font = from_glib_borrow(font);
60 let callback = user_data as *mut P;
61 (*callback)(&fontset, &font).into_glib()
62 }
63 let func = Some(func_func::<P> as _);
64 let super_callback0: &mut P = &mut func_data;
65 unsafe {
66 ffi::pango_fontset_foreach(
67 self.as_ref().to_glib_none().0,
68 func,
69 super_callback0 as *mut _ as *mut _,
70 );
71 }
72 }
73
74 /// Returns the font in the fontset that contains the best
75 /// glyph for a Unicode character.
76 /// ## `wc`
77 /// a Unicode character
78 ///
79 /// # Returns
80 ///
81 /// a [`Font`][crate::Font]
82 #[doc(alias = "pango_fontset_get_font")]
83 #[doc(alias = "get_font")]
84 fn font(&self, wc: u32) -> Font {
85 unsafe {
86 from_glib_full(ffi::pango_fontset_get_font(
87 self.as_ref().to_glib_none().0,
88 wc,
89 ))
90 }
91 }
92
93 /// Get overall metric information for the fonts in the fontset.
94 ///
95 /// # Returns
96 ///
97 /// a [`FontMetrics`][crate::FontMetrics] object
98 #[doc(alias = "pango_fontset_get_metrics")]
99 #[doc(alias = "get_metrics")]
100 fn metrics(&self) -> FontMetrics {
101 unsafe {
102 from_glib_full(ffi::pango_fontset_get_metrics(
103 self.as_ref().to_glib_none().0,
104 ))
105 }
106 }
107}
108
109impl<O: IsA<Fontset>> FontsetExt for O {}