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