pango/auto/
font_face.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
5#[cfg(feature = "v1_46")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
7use crate::FontFamily;
8use crate::{ffi, FontDescription};
9use glib::{prelude::*, translate::*};
10
11glib::wrapper! {
12    /// A [`FontFace`][crate::FontFace] is used to represent a group of fonts with
13    /// the same family, slant, weight, and width, but varying sizes.
14    ///
15    /// This is an Abstract Base Class, you cannot instantiate it.
16    ///
17    /// # Implements
18    ///
19    /// [`FontFaceExt`][trait@crate::prelude::FontFaceExt]
20    #[doc(alias = "PangoFontFace")]
21    pub struct FontFace(Object<ffi::PangoFontFace, ffi::PangoFontFaceClass>);
22
23    match fn {
24        type_ => || ffi::pango_font_face_get_type(),
25    }
26}
27
28impl FontFace {
29    pub const NONE: Option<&'static FontFace> = None;
30}
31
32/// Trait containing all [`struct@FontFace`] methods.
33///
34/// # Implementors
35///
36/// [`FontFace`][struct@crate::FontFace]
37pub trait FontFaceExt: IsA<FontFace> + 'static {
38    /// Returns a font description that matches the face.
39    ///
40    /// The resulting font description will have the family, style,
41    /// variant, weight and stretch of the face, but its size field
42    /// will be unset.
43    ///
44    /// # Returns
45    ///
46    /// a newly-created [`FontDescription`][crate::FontDescription] structure
47    ///   holding the description of the face. Use `Pango::FontDescription::free()`
48    ///   to free the result.
49    #[doc(alias = "pango_font_face_describe")]
50    fn describe(&self) -> FontDescription {
51        unsafe {
52            from_glib_full(ffi::pango_font_face_describe(
53                self.as_ref().to_glib_none().0,
54            ))
55        }
56    }
57
58    /// Gets a name representing the style of this face.
59    ///
60    /// Note that a font family may contain multiple faces
61    /// with the same name (e.g. a variable and a non-variable
62    /// face for the same style).
63    ///
64    /// # Returns
65    ///
66    /// the face name for the face. This string is
67    ///   owned by the face object and must not be modified or freed.
68    #[doc(alias = "pango_font_face_get_face_name")]
69    #[doc(alias = "get_face_name")]
70    fn face_name(&self) -> glib::GString {
71        unsafe {
72            from_glib_none(ffi::pango_font_face_get_face_name(
73                self.as_ref().to_glib_none().0,
74            ))
75        }
76    }
77
78    /// Gets the [`FontFamily`][crate::FontFamily] that @self belongs to.
79    ///
80    /// # Returns
81    ///
82    /// the [`FontFamily`][crate::FontFamily]
83    #[cfg(feature = "v1_46")]
84    #[cfg_attr(docsrs, doc(cfg(feature = "v1_46")))]
85    #[doc(alias = "pango_font_face_get_family")]
86    #[doc(alias = "get_family")]
87    fn family(&self) -> FontFamily {
88        unsafe {
89            from_glib_none(ffi::pango_font_face_get_family(
90                self.as_ref().to_glib_none().0,
91            ))
92        }
93    }
94
95    /// Returns whether a [`FontFace`][crate::FontFace] is synthesized.
96    ///
97    /// This will be the case if the underlying font rendering engine
98    /// creates this face from another face, by shearing, emboldening,
99    /// lightening or modifying it in some other way.
100    ///
101    /// # Returns
102    ///
103    /// whether @self is synthesized
104    #[doc(alias = "pango_font_face_is_synthesized")]
105    fn is_synthesized(&self) -> bool {
106        unsafe {
107            from_glib(ffi::pango_font_face_is_synthesized(
108                self.as_ref().to_glib_none().0,
109            ))
110        }
111    }
112
113    /// List the available sizes for a font.
114    ///
115    /// This is only applicable to bitmap fonts. For scalable fonts, stores
116    /// [`None`] at the location pointed to by @sizes and 0 at the location pointed
117    /// to by @n_sizes. The sizes returned are in Pango units and are sorted
118    /// in ascending order.
119    ///
120    /// # Returns
121    ///
122    ///
123    /// ## `sizes`
124    ///
125    ///   location to store a pointer to an array of int. This array
126    ///   should be freed with g_free().
127    #[doc(alias = "pango_font_face_list_sizes")]
128    fn list_sizes(&self) -> Vec<i32> {
129        unsafe {
130            let mut sizes = std::ptr::null_mut();
131            let mut n_sizes = std::mem::MaybeUninit::uninit();
132            ffi::pango_font_face_list_sizes(
133                self.as_ref().to_glib_none().0,
134                &mut sizes,
135                n_sizes.as_mut_ptr(),
136            );
137            FromGlibContainer::from_glib_full_num(sizes, n_sizes.assume_init() as _)
138        }
139    }
140}
141
142impl<O: IsA<FontFace>> FontFaceExt for O {}