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 use crate::FontMask;
6 use crate::Gravity;
7 use crate::Stretch;
8 use crate::Style;
9 use crate::Variant;
10 use crate::Weight;
11 use glib::translate::*;
12 use std::fmt;
13 use std::hash;
14 
15 glib::wrapper! {
16     #[derive(Debug, PartialOrd, Ord)]
17     pub struct FontDescription(Boxed<ffi::PangoFontDescription>);
18 
19     match fn {
20         copy => |ptr| ffi::pango_font_description_copy(ptr),
21         free => |ptr| ffi::pango_font_description_free(ptr),
22         type_ => || ffi::pango_font_description_get_type(),
23     }
24 }
25 
26 impl FontDescription {
27     #[doc(alias = "pango_font_description_new")]
new() -> FontDescription28     pub fn new() -> FontDescription {
29         unsafe { from_glib_full(ffi::pango_font_description_new()) }
30     }
31 
32     #[doc(alias = "pango_font_description_better_match")]
better_match( &self, old_match: Option<&FontDescription>, new_match: &FontDescription, ) -> bool33     pub fn better_match(
34         &self,
35         old_match: Option<&FontDescription>,
36         new_match: &FontDescription,
37     ) -> bool {
38         unsafe {
39             from_glib(ffi::pango_font_description_better_match(
40                 self.to_glib_none().0,
41                 old_match.to_glib_none().0,
42                 new_match.to_glib_none().0,
43             ))
44         }
45     }
46 
47     #[doc(alias = "pango_font_description_equal")]
equal(&self, desc2: &FontDescription) -> bool48     fn equal(&self, desc2: &FontDescription) -> bool {
49         unsafe {
50             from_glib(ffi::pango_font_description_equal(
51                 self.to_glib_none().0,
52                 desc2.to_glib_none().0,
53             ))
54         }
55     }
56 
57     #[doc(alias = "pango_font_description_get_family")]
58     #[doc(alias = "get_family")]
family(&self) -> Option<glib::GString>59     pub fn family(&self) -> Option<glib::GString> {
60         unsafe {
61             from_glib_none(ffi::pango_font_description_get_family(
62                 self.to_glib_none().0,
63             ))
64         }
65     }
66 
67     #[doc(alias = "pango_font_description_get_gravity")]
68     #[doc(alias = "get_gravity")]
gravity(&self) -> Gravity69     pub fn gravity(&self) -> Gravity {
70         unsafe {
71             from_glib(ffi::pango_font_description_get_gravity(
72                 self.to_glib_none().0,
73             ))
74         }
75     }
76 
77     #[doc(alias = "pango_font_description_get_set_fields")]
78     #[doc(alias = "get_set_fields")]
set_fields(&self) -> FontMask79     pub fn set_fields(&self) -> FontMask {
80         unsafe {
81             from_glib(ffi::pango_font_description_get_set_fields(
82                 self.to_glib_none().0,
83             ))
84         }
85     }
86 
87     #[doc(alias = "pango_font_description_get_size")]
88     #[doc(alias = "get_size")]
size(&self) -> i3289     pub fn size(&self) -> i32 {
90         unsafe { ffi::pango_font_description_get_size(self.to_glib_none().0) }
91     }
92 
93     #[doc(alias = "pango_font_description_get_size_is_absolute")]
94     #[doc(alias = "get_size_is_absolute")]
is_size_absolute(&self) -> bool95     pub fn is_size_absolute(&self) -> bool {
96         unsafe {
97             from_glib(ffi::pango_font_description_get_size_is_absolute(
98                 self.to_glib_none().0,
99             ))
100         }
101     }
102 
103     #[doc(alias = "pango_font_description_get_stretch")]
104     #[doc(alias = "get_stretch")]
stretch(&self) -> Stretch105     pub fn stretch(&self) -> Stretch {
106         unsafe {
107             from_glib(ffi::pango_font_description_get_stretch(
108                 self.to_glib_none().0,
109             ))
110         }
111     }
112 
113     #[doc(alias = "pango_font_description_get_style")]
114     #[doc(alias = "get_style")]
style(&self) -> Style115     pub fn style(&self) -> Style {
116         unsafe { from_glib(ffi::pango_font_description_get_style(self.to_glib_none().0)) }
117     }
118 
119     #[doc(alias = "pango_font_description_get_variant")]
120     #[doc(alias = "get_variant")]
variant(&self) -> Variant121     pub fn variant(&self) -> Variant {
122         unsafe {
123             from_glib(ffi::pango_font_description_get_variant(
124                 self.to_glib_none().0,
125             ))
126         }
127     }
128 
129     #[cfg(any(feature = "v1_42", feature = "dox"))]
130     #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_42")))]
131     #[doc(alias = "pango_font_description_get_variations")]
132     #[doc(alias = "get_variations")]
variations(&self) -> Option<glib::GString>133     pub fn variations(&self) -> Option<glib::GString> {
134         unsafe {
135             from_glib_none(ffi::pango_font_description_get_variations(
136                 self.to_glib_none().0,
137             ))
138         }
139     }
140 
141     #[doc(alias = "pango_font_description_get_weight")]
142     #[doc(alias = "get_weight")]
weight(&self) -> Weight143     pub fn weight(&self) -> Weight {
144         unsafe {
145             from_glib(ffi::pango_font_description_get_weight(
146                 self.to_glib_none().0,
147             ))
148         }
149     }
150 
151     #[doc(alias = "pango_font_description_hash")]
hash(&self) -> u32152     fn hash(&self) -> u32 {
153         unsafe { ffi::pango_font_description_hash(self.to_glib_none().0) }
154     }
155 
156     #[doc(alias = "pango_font_description_merge")]
merge(&mut self, desc_to_merge: Option<&FontDescription>, replace_existing: bool)157     pub fn merge(&mut self, desc_to_merge: Option<&FontDescription>, replace_existing: bool) {
158         unsafe {
159             ffi::pango_font_description_merge(
160                 self.to_glib_none_mut().0,
161                 desc_to_merge.to_glib_none().0,
162                 replace_existing.into_glib(),
163             );
164         }
165     }
166 
167     #[doc(alias = "pango_font_description_set_absolute_size")]
set_absolute_size(&mut self, size: f64)168     pub fn set_absolute_size(&mut self, size: f64) {
169         unsafe {
170             ffi::pango_font_description_set_absolute_size(self.to_glib_none_mut().0, size);
171         }
172     }
173 
174     #[doc(alias = "pango_font_description_set_family")]
set_family(&mut self, family: &str)175     pub fn set_family(&mut self, family: &str) {
176         unsafe {
177             ffi::pango_font_description_set_family(
178                 self.to_glib_none_mut().0,
179                 family.to_glib_none().0,
180             );
181         }
182     }
183 
184     #[doc(alias = "pango_font_description_set_gravity")]
set_gravity(&mut self, gravity: Gravity)185     pub fn set_gravity(&mut self, gravity: Gravity) {
186         unsafe {
187             ffi::pango_font_description_set_gravity(self.to_glib_none_mut().0, gravity.into_glib());
188         }
189     }
190 
191     #[doc(alias = "pango_font_description_set_size")]
set_size(&mut self, size: i32)192     pub fn set_size(&mut self, size: i32) {
193         unsafe {
194             ffi::pango_font_description_set_size(self.to_glib_none_mut().0, size);
195         }
196     }
197 
198     #[doc(alias = "pango_font_description_set_stretch")]
set_stretch(&mut self, stretch: Stretch)199     pub fn set_stretch(&mut self, stretch: Stretch) {
200         unsafe {
201             ffi::pango_font_description_set_stretch(self.to_glib_none_mut().0, stretch.into_glib());
202         }
203     }
204 
205     #[doc(alias = "pango_font_description_set_style")]
set_style(&mut self, style: Style)206     pub fn set_style(&mut self, style: Style) {
207         unsafe {
208             ffi::pango_font_description_set_style(self.to_glib_none_mut().0, style.into_glib());
209         }
210     }
211 
212     #[doc(alias = "pango_font_description_set_variant")]
set_variant(&mut self, variant: Variant)213     pub fn set_variant(&mut self, variant: Variant) {
214         unsafe {
215             ffi::pango_font_description_set_variant(self.to_glib_none_mut().0, variant.into_glib());
216         }
217     }
218 
219     #[cfg(any(feature = "v1_42", feature = "dox"))]
220     #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_42")))]
221     #[doc(alias = "pango_font_description_set_variations")]
set_variations(&mut self, variations: &str)222     pub fn set_variations(&mut self, variations: &str) {
223         unsafe {
224             ffi::pango_font_description_set_variations(
225                 self.to_glib_none_mut().0,
226                 variations.to_glib_none().0,
227             );
228         }
229     }
230 
231     #[cfg(any(feature = "v1_42", feature = "dox"))]
232     #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_42")))]
233     #[doc(alias = "pango_font_description_set_variations_static")]
set_variations_static(&mut self, variations: &str)234     pub fn set_variations_static(&mut self, variations: &str) {
235         unsafe {
236             ffi::pango_font_description_set_variations_static(
237                 self.to_glib_none_mut().0,
238                 variations.to_glib_none().0,
239             );
240         }
241     }
242 
243     #[doc(alias = "pango_font_description_set_weight")]
set_weight(&mut self, weight: Weight)244     pub fn set_weight(&mut self, weight: Weight) {
245         unsafe {
246             ffi::pango_font_description_set_weight(self.to_glib_none_mut().0, weight.into_glib());
247         }
248     }
249 
250     #[doc(alias = "pango_font_description_to_filename")]
to_filename(&self) -> Option<glib::GString>251     pub fn to_filename(&self) -> Option<glib::GString> {
252         unsafe {
253             from_glib_full(ffi::pango_font_description_to_filename(
254                 self.to_glib_none().0,
255             ))
256         }
257     }
258 
259     #[doc(alias = "pango_font_description_to_string")]
260     #[doc(alias = "to_string")]
to_str(&self) -> glib::GString261     pub fn to_str(&self) -> glib::GString {
262         unsafe { from_glib_full(ffi::pango_font_description_to_string(self.to_glib_none().0)) }
263     }
264 
265     #[doc(alias = "pango_font_description_unset_fields")]
unset_fields(&mut self, to_unset: FontMask)266     pub fn unset_fields(&mut self, to_unset: FontMask) {
267         unsafe {
268             ffi::pango_font_description_unset_fields(
269                 self.to_glib_none_mut().0,
270                 to_unset.into_glib(),
271             );
272         }
273     }
274 
275     #[doc(alias = "pango_font_description_from_string")]
from_string(str: &str) -> FontDescription276     pub fn from_string(str: &str) -> FontDescription {
277         unsafe {
278             from_glib_full(ffi::pango_font_description_from_string(
279                 str.to_glib_none().0,
280             ))
281         }
282     }
283 }
284 
285 impl Default for FontDescription {
default() -> Self286     fn default() -> Self {
287         Self::new()
288     }
289 }
290 
291 impl PartialEq for FontDescription {
292     #[inline]
eq(&self, other: &Self) -> bool293     fn eq(&self, other: &Self) -> bool {
294         self.equal(other)
295     }
296 }
297 
298 impl Eq for FontDescription {}
299 
300 impl fmt::Display for FontDescription {
301     #[inline]
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result302     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
303         f.write_str(&self.to_str())
304     }
305 }
306 
307 impl hash::Hash for FontDescription {
308     #[inline]
hash<H>(&self, state: &mut H) where H: hash::Hasher,309     fn hash<H>(&self, state: &mut H)
310     where
311         H: hash::Hasher,
312     {
313         hash::Hash::hash(&self.hash(), state)
314     }
315 }
316