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