1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::{prelude::*, translate::*};
use std::fmt;

glib::wrapper! {
    /// [`Font`][crate::Font] is an interface exported by fonts for
    /// use with Cairo.
    ///
    /// The actual type of the font will depend on the particular
    /// font technology Cairo was compiled to use.
    ///
    /// # Implements
    ///
    /// [`PangoCairoFontExt`][trait@crate::prelude::PangoCairoFontExt], [`trait@pango::prelude::FontExt`]
    #[doc(alias = "PangoCairoFont")]
    pub struct Font(Interface<ffi::PangoCairoFont>) @requires pango::Font;

    match fn {
        type_ => || ffi::pango_cairo_font_get_type(),
    }
}

impl Font {
    pub const NONE: Option<&'static Font> = None;
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Font>> Sealed for T {}
}

/// Trait containing all [`struct@Font`] methods.
///
/// # Implementors
///
/// [`Font`][struct@crate::Font]
pub trait PangoCairoFontExt: IsA<Font> + sealed::Sealed + 'static {
    /// Gets the [`cairo::ScaledFont`][crate::cairo::ScaledFont] used by `self`.
    /// The scaled font can be referenced and kept using
    /// `cairo_scaled_font_reference()`.
    ///
    /// # Returns
    ///
    /// the [`cairo::ScaledFont`][crate::cairo::ScaledFont]
    ///  used by `self`
    #[doc(alias = "pango_cairo_font_get_scaled_font")]
    #[doc(alias = "get_scaled_font")]
    fn scaled_font(&self) -> Option<cairo::ScaledFont> {
        unsafe {
            from_glib_none(ffi::pango_cairo_font_get_scaled_font(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<Font>> PangoCairoFontExt for O {}

impl fmt::Display for Font {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Font")
    }
}