Skip to main content

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
5#[cfg(feature = "v1_57")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
7use crate::FontColor;
8#[cfg(feature = "v1_58")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v1_58")))]
10use crate::Width;
11use crate::{FontMask, Gravity, Stretch, Style, Variant, Weight, ffi};
12use glib::translate::*;
13
14glib::wrapper! {
15    /// A [`FontDescription`][crate::FontDescription] describes a font in an implementation-independent
16    /// manner.
17    ///
18    /// [`FontDescription`][crate::FontDescription] structures are used both to list what fonts are
19    /// available on the system and also for specifying the characteristics of
20    /// a font to load.
21    #[derive(Debug, PartialOrd, Ord)]
22    pub struct FontDescription(Boxed<ffi::PangoFontDescription>);
23
24    match fn {
25        copy => |ptr| ffi::pango_font_description_copy(ptr),
26        free => |ptr| ffi::pango_font_description_free(ptr),
27        type_ => || ffi::pango_font_description_get_type(),
28    }
29}
30
31impl FontDescription {
32    /// Creates a new font description structure with all fields unset.
33    ///
34    /// # Returns
35    ///
36    /// the newly allocated [`FontDescription`][crate::FontDescription],
37    ///   which should be freed using `Pango::FontDescription::free()`.
38    #[doc(alias = "pango_font_description_new")]
39    pub fn new() -> FontDescription {
40        unsafe { from_glib_full(ffi::pango_font_description_new()) }
41    }
42
43    /// Determines if the style attributes of @new_match are a closer match
44    /// for @self than those of @old_match are, or if @old_match is [`None`],
45    /// determines if @new_match is a match at all.
46    ///
47    /// Approximate matching is done for weight, width and style; other style attributes
48    /// must match exactly. Style attributes are all attributes other than family
49    /// and size-related attributes. Approximate matching for style considers
50    /// [`Style::Oblique`][crate::Style::Oblique] and [`Style::Italic`][crate::Style::Italic] as matches, but not as good
51    /// a match as when the styles are equal.
52    ///
53    /// Note that @old_match must match @self.
54    /// ## `old_match`
55    /// a [`FontDescription`][crate::FontDescription], or [`None`]
56    /// ## `new_match`
57    /// a [`FontDescription`][crate::FontDescription]
58    ///
59    /// # Returns
60    ///
61    /// [`true`] if @new_match is a better match
62    #[doc(alias = "pango_font_description_better_match")]
63    pub fn better_match(
64        &self,
65        old_match: Option<&FontDescription>,
66        new_match: &FontDescription,
67    ) -> bool {
68        unsafe {
69            from_glib(ffi::pango_font_description_better_match(
70                self.to_glib_none().0,
71                old_match.to_glib_none().0,
72                new_match.to_glib_none().0,
73            ))
74        }
75    }
76
77    #[doc(alias = "pango_font_description_equal")]
78    fn equal(&self, desc2: &FontDescription) -> bool {
79        unsafe {
80            from_glib(ffi::pango_font_description_equal(
81                self.to_glib_none().0,
82                desc2.to_glib_none().0,
83            ))
84        }
85    }
86
87    /// Returns the color field of the font description.
88    ///
89    /// This field determines whether the font description should
90    /// match fonts that have color glyphs, or fonts that don't.
91    #[cfg(feature = "v1_57")]
92    #[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
93    #[doc(alias = "pango_font_description_get_color")]
94    #[doc(alias = "get_color")]
95    pub fn color(&self) -> FontColor {
96        unsafe { from_glib(ffi::pango_font_description_get_color(self.to_glib_none().0)) }
97    }
98
99    /// Gets the family name field of a font description.
100    ///
101    /// See [`set_family()`][Self::set_family()].
102    ///
103    /// # Returns
104    ///
105    /// the family name field for the
106    ///   font description, or [`None`] if not previously set. This has the same
107    ///   life-time as the font description itself and should not be freed.
108    #[doc(alias = "pango_font_description_get_family")]
109    #[doc(alias = "get_family")]
110    pub fn family(&self) -> Option<glib::GString> {
111        unsafe {
112            from_glib_none(ffi::pango_font_description_get_family(
113                self.to_glib_none().0,
114            ))
115        }
116    }
117
118    /// Gets the features field of a font description.
119    ///
120    /// See [`set_features()`][Self::set_features()].
121    ///
122    /// # Returns
123    ///
124    /// the features field for the font
125    ///   description, or [`None`] if not previously set. This has the same
126    ///   life-time as the font description itself and should not be freed.
127    #[cfg(feature = "v1_56")]
128    #[cfg_attr(docsrs, doc(cfg(feature = "v1_56")))]
129    #[doc(alias = "pango_font_description_get_features")]
130    #[doc(alias = "get_features")]
131    pub fn features(&self) -> Option<glib::GString> {
132        unsafe {
133            from_glib_none(ffi::pango_font_description_get_features(
134                self.to_glib_none().0,
135            ))
136        }
137    }
138
139    /// Gets the gravity field of a font description.
140    ///
141    /// See [`set_gravity()`][Self::set_gravity()].
142    ///
143    /// # Returns
144    ///
145    /// the gravity field for the font description.
146    ///   Use [`set_fields()`][Self::set_fields()] to find out
147    ///   if the field was explicitly set or not.
148    #[doc(alias = "pango_font_description_get_gravity")]
149    #[doc(alias = "get_gravity")]
150    pub fn gravity(&self) -> Gravity {
151        unsafe {
152            from_glib(ffi::pango_font_description_get_gravity(
153                self.to_glib_none().0,
154            ))
155        }
156    }
157
158    /// Determines which fields in a font description have been set.
159    ///
160    /// # Returns
161    ///
162    /// a bitmask with bits set corresponding to the
163    ///   fields in @self that have been set.
164    #[doc(alias = "pango_font_description_get_set_fields")]
165    #[doc(alias = "get_set_fields")]
166    pub fn set_fields(&self) -> FontMask {
167        unsafe {
168            from_glib(ffi::pango_font_description_get_set_fields(
169                self.to_glib_none().0,
170            ))
171        }
172    }
173
174    /// Gets the size field of a font description.
175    ///
176    /// See [`set_size()`][Self::set_size()].
177    ///
178    /// # Returns
179    ///
180    /// the size field for the font description in points
181    ///   or device units. You must call
182    ///   [`is_size_absolute()`][Self::is_size_absolute()] to find out
183    ///   which is the case. Returns 0 if the size field has not previously
184    ///   been set or it has been set to 0 explicitly.
185    ///   Use [`set_fields()`][Self::set_fields()] to find out
186    ///   if the field was explicitly set or not.
187    #[doc(alias = "pango_font_description_get_size")]
188    #[doc(alias = "get_size")]
189    pub fn size(&self) -> i32 {
190        unsafe { ffi::pango_font_description_get_size(self.to_glib_none().0) }
191    }
192
193    /// Determines whether the size of the font is in points (not absolute)
194    /// or device units (absolute).
195    ///
196    /// See [`set_size()`][Self::set_size()]
197    /// and [`set_absolute_size()`][Self::set_absolute_size()].
198    ///
199    /// # Returns
200    ///
201    /// whether the size for the font description is in
202    ///   points or device units. Use [`set_fields()`][Self::set_fields()]
203    ///   to find out if the size field of the font description was explicitly
204    ///   set or not.
205    #[doc(alias = "pango_font_description_get_size_is_absolute")]
206    #[doc(alias = "get_size_is_absolute")]
207    pub fn is_size_absolute(&self) -> bool {
208        unsafe {
209            from_glib(ffi::pango_font_description_get_size_is_absolute(
210                self.to_glib_none().0,
211            ))
212        }
213    }
214
215    /// Gets the stretch field of a font description.
216    ///
217    /// See [`set_stretch()`][Self::set_stretch()].
218    ///
219    /// # Returns
220    ///
221    /// the stretch field for the font description.
222    ///   Use [`set_fields()`][Self::set_fields()] to find
223    ///   out if the field was explicitly set or not.
224    #[doc(alias = "pango_font_description_get_stretch")]
225    #[doc(alias = "get_stretch")]
226    pub fn stretch(&self) -> Stretch {
227        unsafe {
228            from_glib(ffi::pango_font_description_get_stretch(
229                self.to_glib_none().0,
230            ))
231        }
232    }
233
234    /// Gets the style field of a [`FontDescription`][crate::FontDescription].
235    ///
236    /// See [`set_style()`][Self::set_style()].
237    ///
238    /// # Returns
239    ///
240    /// the style field for the font description.
241    ///   Use [`set_fields()`][Self::set_fields()] to
242    ///   find out if the field was explicitly set or not.
243    #[doc(alias = "pango_font_description_get_style")]
244    #[doc(alias = "get_style")]
245    pub fn style(&self) -> Style {
246        unsafe { from_glib(ffi::pango_font_description_get_style(self.to_glib_none().0)) }
247    }
248
249    /// Gets the variant field of a [`FontDescription`][crate::FontDescription].
250    ///
251    /// See [`set_variant()`][Self::set_variant()].
252    ///
253    /// # Returns
254    ///
255    /// the variant field for the font description.
256    ///   Use [`set_fields()`][Self::set_fields()] to find
257    ///   out if the field was explicitly set or not.
258    #[doc(alias = "pango_font_description_get_variant")]
259    #[doc(alias = "get_variant")]
260    pub fn variant(&self) -> Variant {
261        unsafe {
262            from_glib(ffi::pango_font_description_get_variant(
263                self.to_glib_none().0,
264            ))
265        }
266    }
267
268    /// Gets the variations field of a font description.
269    ///
270    /// See [`set_variations()`][Self::set_variations()].
271    ///
272    /// # Returns
273    ///
274    /// the variations field for the font
275    ///   description, or [`None`] if not previously set. This has the same
276    ///   life-time as the font description itself and should not be freed.
277    #[cfg(feature = "v1_42")]
278    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
279    #[doc(alias = "pango_font_description_get_variations")]
280    #[doc(alias = "get_variations")]
281    pub fn variations(&self) -> Option<glib::GString> {
282        unsafe {
283            from_glib_none(ffi::pango_font_description_get_variations(
284                self.to_glib_none().0,
285            ))
286        }
287    }
288
289    /// Gets the weight field of a font description.
290    ///
291    /// See [`set_weight()`][Self::set_weight()].
292    ///
293    /// # Returns
294    ///
295    /// the weight field for the font description.
296    ///   Use [`set_fields()`][Self::set_fields()] to find
297    ///   out if the field was explicitly set or not.
298    #[doc(alias = "pango_font_description_get_weight")]
299    #[doc(alias = "get_weight")]
300    pub fn weight(&self) -> Weight {
301        unsafe {
302            from_glib(ffi::pango_font_description_get_weight(
303                self.to_glib_none().0,
304            ))
305        }
306    }
307
308    /// Gets the width field of a font description.
309    ///
310    /// See [`set_width()`][Self::set_width()].
311    ///
312    /// # Returns
313    ///
314    /// the width field for the font description.
315    ///   Use [`set_fields()`][Self::set_fields()] to find
316    ///   out if the field was explicitly set or not.
317    #[cfg(feature = "v1_58")]
318    #[cfg_attr(docsrs, doc(cfg(feature = "v1_58")))]
319    #[doc(alias = "pango_font_description_get_width")]
320    #[doc(alias = "get_width")]
321    pub fn width(&self) -> Width {
322        unsafe { from_glib(ffi::pango_font_description_get_width(self.to_glib_none().0)) }
323    }
324
325    #[doc(alias = "pango_font_description_hash")]
326    fn hash(&self) -> u32 {
327        unsafe { ffi::pango_font_description_hash(self.to_glib_none().0) }
328    }
329
330    /// Merges the fields that are set in @desc_to_merge into the fields in
331    /// @self.
332    ///
333    /// If @replace_existing is [`false`], only fields in @self that
334    /// are not already set are affected. If [`true`], then fields that are
335    /// already set will be replaced as well.
336    ///
337    /// If @desc_to_merge is [`None`], this function performs nothing.
338    /// ## `desc_to_merge`
339    /// the [`FontDescription`][crate::FontDescription] to merge from,
340    ///   or [`None`]
341    /// ## `replace_existing`
342    /// if [`true`], replace fields in @self with the
343    ///   corresponding values from @desc_to_merge, even if they
344    ///   are already exist.
345    #[doc(alias = "pango_font_description_merge")]
346    pub fn merge(&mut self, desc_to_merge: Option<&FontDescription>, replace_existing: bool) {
347        unsafe {
348            ffi::pango_font_description_merge(
349                self.to_glib_none_mut().0,
350                desc_to_merge.to_glib_none().0,
351                replace_existing.into_glib(),
352            );
353        }
354    }
355
356    /// Sets the size field of a font description, in device units.
357    ///
358    /// This is mutually exclusive with [`set_size()`][Self::set_size()]
359    /// which sets the font size in points.
360    /// ## `size`
361    /// the new size, in Pango units. There are `PANGO_SCALE` Pango units
362    ///   in one device unit. For an output backend where a device unit is a pixel,
363    ///   a @size value of 10 * PANGO_SCALE gives a 10 pixel font.
364    #[doc(alias = "pango_font_description_set_absolute_size")]
365    pub fn set_absolute_size(&mut self, size: f64) {
366        unsafe {
367            ffi::pango_font_description_set_absolute_size(self.to_glib_none_mut().0, size);
368        }
369    }
370
371    /// Sets the color field of a font description.
372    ///
373    /// This field determines whether the font description should
374    /// match fonts that have color glyphs, or fonts that don't.
375    /// ## `color`
376    /// the [`FontColor`][crate::FontColor] value
377    #[cfg(feature = "v1_57")]
378    #[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
379    #[doc(alias = "pango_font_description_set_color")]
380    pub fn set_color(&mut self, color: FontColor) {
381        unsafe {
382            ffi::pango_font_description_set_color(self.to_glib_none_mut().0, color.into_glib());
383        }
384    }
385
386    /// Sets the family name field of a font description.
387    ///
388    /// The family
389    /// name represents a family of related font styles, and will
390    /// resolve to a particular [`FontFamily`][crate::FontFamily]. In some uses of
391    /// [`FontDescription`][crate::FontDescription], it is also possible to use a comma
392    /// separated list of family names for this field.
393    /// ## `family`
394    /// a string representing the family name.
395    #[doc(alias = "pango_font_description_set_family")]
396    pub fn set_family(&mut self, family: &str) {
397        unsafe {
398            ffi::pango_font_description_set_family(
399                self.to_glib_none_mut().0,
400                family.to_glib_none().0,
401            );
402        }
403    }
404
405    /// Sets the features field of a font description.
406    ///
407    /// OpenType font features allow to enable or disable certain optional
408    /// features of a font, such as tabular numbers.
409    ///
410    /// The format of the features string is comma-separated list of
411    /// feature assignments, with each assignment being one of these forms:
412    ///
413    ///     FEATURE=n
414    ///
415    /// where FEATURE must be a 4 character tag that identifies and OpenType
416    /// feature, and n an integer (depending on the feature, the allowed
417    /// values may be 0, 1 or bigger numbers). Unknown features are ignored.
418    ///
419    /// Note that font features set in this way are enabled for the entire text
420    /// that is using the font, which is not appropriate for all OpenType features.
421    /// The intended use case is to select character variations (features cv01 - c99),
422    /// style sets (ss01 - ss20) and the like.
423    ///
424    /// Pango does not currently have a way to find supported OpenType features
425    /// of a font. Both harfbuzz and freetype have API for this. See for example
426    /// [hb_ot_layout_table_get_feature_tags](https://harfbuzz.github.io/harfbuzz-hb-ot-layout.html#hb-ot-layout-table-get-feature-tags).
427    ///
428    /// Features that are not supported by the font are silently ignored.
429    /// ## `features`
430    /// a string representing the features
431    #[cfg(feature = "v1_56")]
432    #[cfg_attr(docsrs, doc(cfg(feature = "v1_56")))]
433    #[doc(alias = "pango_font_description_set_features")]
434    pub fn set_features(&mut self, features: Option<&str>) {
435        unsafe {
436            ffi::pango_font_description_set_features(
437                self.to_glib_none_mut().0,
438                features.to_glib_none().0,
439            );
440        }
441    }
442
443    /// Sets the gravity field of a font description.
444    ///
445    /// The gravity field
446    /// specifies how the glyphs should be rotated. If @gravity is
447    /// [`Gravity::Auto`][crate::Gravity::Auto], this actually unsets the gravity mask on
448    /// the font description.
449    ///
450    /// This function is seldom useful to the user. Gravity should normally
451    /// be set on a [`Context`][crate::Context].
452    /// ## `gravity`
453    /// the gravity for the font description.
454    #[doc(alias = "pango_font_description_set_gravity")]
455    pub fn set_gravity(&mut self, gravity: Gravity) {
456        unsafe {
457            ffi::pango_font_description_set_gravity(self.to_glib_none_mut().0, gravity.into_glib());
458        }
459    }
460
461    /// Sets the size field of a font description in fractional points.
462    ///
463    /// This is mutually exclusive with
464    /// [`set_absolute_size()`][Self::set_absolute_size()].
465    /// ## `size`
466    /// the size of the font in points, scaled by `PANGO_SCALE`.
467    ///   (That is, a @size value of 10 * PANGO_SCALE is a 10 point font.
468    ///   The conversion factor between points and device units depends on
469    ///   system configuration and the output device. For screen display, a
470    ///   logical DPI of 96 is common, in which case a 10 point font corresponds
471    ///   to a 10 * (96 / 72) = 13.3 pixel font.
472    ///   Use [`set_absolute_size()`][Self::set_absolute_size()] if you need
473    ///   a particular size in device units.
474    #[doc(alias = "pango_font_description_set_size")]
475    pub fn set_size(&mut self, size: i32) {
476        unsafe {
477            ffi::pango_font_description_set_size(self.to_glib_none_mut().0, size);
478        }
479    }
480
481    /// Sets the stretch field of a font description.
482    ///
483    /// The [`Stretch`][crate::Stretch] field specifies how narrow or
484    /// wide the font should be.
485    /// ## `stretch`
486    /// the stretch for the font description
487    #[doc(alias = "pango_font_description_set_stretch")]
488    pub fn set_stretch(&mut self, stretch: Stretch) {
489        unsafe {
490            ffi::pango_font_description_set_stretch(self.to_glib_none_mut().0, stretch.into_glib());
491        }
492    }
493
494    /// Sets the style field of a [`FontDescription`][crate::FontDescription].
495    ///
496    /// The [`Style`][crate::Style] enumeration describes whether the font is
497    /// slanted and the manner in which it is slanted; it can be either
498    /// [`Style::Normal`][crate::Style::Normal], [`Style::Italic`][crate::Style::Italic], or [`Style::Oblique`][crate::Style::Oblique].
499    ///
500    /// Most fonts will either have a italic style or an oblique style,
501    /// but not both, and font matching in Pango will match italic
502    /// specifications with oblique fonts and vice-versa if an exact
503    /// match is not found.
504    /// ## `style`
505    /// the style for the font description
506    #[doc(alias = "pango_font_description_set_style")]
507    pub fn set_style(&mut self, style: Style) {
508        unsafe {
509            ffi::pango_font_description_set_style(self.to_glib_none_mut().0, style.into_glib());
510        }
511    }
512
513    /// Sets the variant field of a font description.
514    ///
515    /// The [`Variant`][struct@crate::Variant] can either be [`Variant::Normal`][crate::Variant::Normal]
516    /// or [`Variant::SmallCaps`][crate::Variant::SmallCaps].
517    /// ## `variant`
518    /// the variant type for the font description.
519    #[doc(alias = "pango_font_description_set_variant")]
520    pub fn set_variant(&mut self, variant: Variant) {
521        unsafe {
522            ffi::pango_font_description_set_variant(self.to_glib_none_mut().0, variant.into_glib());
523        }
524    }
525
526    /// Sets the variations field of a font description.
527    ///
528    /// OpenType font variations allow to select a font instance by
529    /// specifying values for a number of axes, such as width or weight.
530    ///
531    /// The format of the variations string is
532    ///
533    ///     AXIS1=VALUE,AXIS2=VALUE...
534    ///
535    /// with each AXIS a 4 character tag that identifies a font axis,
536    /// and each VALUE a floating point number. Unknown axes are ignored,
537    /// and values are clamped to their allowed range.
538    ///
539    /// Pango does not currently have a way to find supported axes of
540    /// a font. Both harfbuzz and freetype have API for this. See
541    /// for example [hb_ot_var_get_axis_infos](https://harfbuzz.github.io/harfbuzz-hb-ot-var.html#hb-ot-var-get-axis-infos).
542    /// ## `variations`
543    /// a string representing the variations
544    #[cfg(feature = "v1_42")]
545    #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
546    #[doc(alias = "pango_font_description_set_variations")]
547    pub fn set_variations(&mut self, variations: Option<&str>) {
548        unsafe {
549            ffi::pango_font_description_set_variations(
550                self.to_glib_none_mut().0,
551                variations.to_glib_none().0,
552            );
553        }
554    }
555
556    /// Sets the weight field of a font description.
557    ///
558    /// The weight field
559    /// specifies how bold or light the font should be. In addition
560    /// to the values of the [`Weight`][crate::Weight] enumeration, other
561    /// intermediate numeric values are possible.
562    /// ## `weight`
563    /// the weight for the font description.
564    #[doc(alias = "pango_font_description_set_weight")]
565    pub fn set_weight(&mut self, weight: Weight) {
566        unsafe {
567            ffi::pango_font_description_set_weight(self.to_glib_none_mut().0, weight.into_glib());
568        }
569    }
570
571    /// Sets the width field of a font description.
572    ///
573    /// The width field specifies how narrow or wide the
574    /// font should be. In addition to the values of the
575    /// [`Width`][crate::Width] enumeration, other
576    /// intermediate numeric values are possible.
577    /// ## `width`
578    /// the width for the font description
579    #[cfg(feature = "v1_58")]
580    #[cfg_attr(docsrs, doc(cfg(feature = "v1_58")))]
581    #[doc(alias = "pango_font_description_set_width")]
582    pub fn set_width(&mut self, width: Width) {
583        unsafe {
584            ffi::pango_font_description_set_width(self.to_glib_none_mut().0, width.into_glib());
585        }
586    }
587
588    /// Creates a filename representation of a font description.
589    ///
590    /// The filename is identical to the result from calling
591    /// [`to_str()`][Self::to_str()], but with underscores
592    /// instead of characters that are untypical in filenames, and in
593    /// lower case only.
594    ///
595    /// # Returns
596    ///
597    /// a new string that must be freed with g_free().
598    #[doc(alias = "pango_font_description_to_filename")]
599    pub fn to_filename(&self) -> Option<glib::GString> {
600        unsafe {
601            from_glib_full(ffi::pango_font_description_to_filename(
602                self.to_glib_none().0,
603            ))
604        }
605    }
606
607    /// Creates a string representation of a font description.
608    ///
609    /// See [`from_string()`][Self::from_string()] for a description
610    /// of the format of the string representation. The family list in
611    /// the string description will only have a terminating comma if
612    /// the last word of the list is a valid style option.
613    ///
614    /// # Returns
615    ///
616    /// a new string that must be freed with g_free().
617    #[doc(alias = "pango_font_description_to_string")]
618    #[doc(alias = "to_string")]
619    pub fn to_str(&self) -> glib::GString {
620        unsafe { from_glib_full(ffi::pango_font_description_to_string(self.to_glib_none().0)) }
621    }
622
623    /// Unsets some of the fields in a [`FontDescription`][crate::FontDescription].
624    ///
625    /// The unset fields will get back to their default values.
626    /// ## `to_unset`
627    /// bitmask of fields in the @self to unset.
628    #[doc(alias = "pango_font_description_unset_fields")]
629    pub fn unset_fields(&mut self, to_unset: FontMask) {
630        unsafe {
631            ffi::pango_font_description_unset_fields(
632                self.to_glib_none_mut().0,
633                to_unset.into_glib(),
634            );
635        }
636    }
637
638    /// Creates a new font description from a string representation.
639    ///
640    /// The string must have the form
641    ///
642    ///     [FAMILY-LIST] [STYLE-OPTIONS] [SIZE] [VARIATIONS] [FEATURES]
643    ///
644    /// where FAMILY-LIST is a comma-separated list of families optionally
645    /// terminated by a comma, STYLE_OPTIONS is a whitespace-separated list
646    /// of words where each word describes one of style, variant, weight,
647    /// stretch, or gravity, and SIZE is a decimal number (size in points)
648    /// or optionally followed by the unit modifier "px" for absolute size.
649    ///
650    /// The following words are understood as styles:
651    /// "Normal", "Roman", "Oblique", "Italic".
652    ///
653    /// The following words are understood as variants:
654    /// "Small-Caps", "All-Small-Caps", "Petite-Caps", "All-Petite-Caps",
655    /// "Unicase", "Title-Caps".
656    ///
657    /// The following words are understood as weights:
658    /// "Thin", "Ultra-Light", "Extra-Light", "Light", "Semi-Light",
659    /// "Demi-Light", "Book", "Regular", "Medium", "Semi-Bold", "Demi-Bold",
660    /// "Bold", "Ultra-Bold", "Extra-Bold", "Heavy", "Black", "Ultra-Black",
661    /// "Extra-Black".
662    ///
663    /// The following words are understood as stretch values:
664    /// "Ultra-Condensed", "Extra-Condensed", "Condensed", "Semi-Condensed",
665    /// "Semi-Expanded", "Expanded", "Extra-Expanded", "Ultra-Expanded".
666    ///
667    /// The following words are understood as gravity values:
668    /// "Not-Rotated", "South", "Upside-Down", "North", "Rotated-Left",
669    /// "East", "Rotated-Right", "West".
670    ///
671    /// The following words are understood as color values:
672    /// "With-Color", "Without-Color".
673    ///
674    /// VARIATIONS is a comma-separated list of font variations
675    /// of the form @‍axis1=value,axis2=value,...
676    ///
677    /// FEATURES is a comma-separated list of font features of the form
678    /// \#‍feature1=value,feature2=value,...
679    /// The =value part can be ommitted if the value is 1.
680    ///
681    /// Any one of the options may be absent. If FAMILY-LIST is absent, then
682    /// the family_name field of the resulting font description will be
683    /// initialized to [`None`]. If STYLE-OPTIONS is missing, then all style
684    /// options will be set to the default values. If SIZE is missing, the
685    /// size in the resulting font description will be set to 0.
686    ///
687    /// A typical example:
688    ///
689    ///     Cantarell Italic Light 15 @‍wght=200 #‍tnum=1
690    /// ## `str`
691    /// string representation of a font description.
692    ///
693    /// # Returns
694    ///
695    /// a new [`FontDescription`][crate::FontDescription].
696    #[doc(alias = "pango_font_description_from_string")]
697    pub fn from_string(str: &str) -> FontDescription {
698        unsafe {
699            from_glib_full(ffi::pango_font_description_from_string(
700                str.to_glib_none().0,
701            ))
702        }
703    }
704}
705
706impl Default for FontDescription {
707    fn default() -> Self {
708        Self::new()
709    }
710}
711
712impl PartialEq for FontDescription {
713    #[inline]
714    fn eq(&self, other: &Self) -> bool {
715        self.equal(other)
716    }
717}
718
719impl Eq for FontDescription {}
720
721impl std::fmt::Display for FontDescription {
722    #[inline]
723    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
724        f.write_str(&self.to_str())
725    }
726}
727
728impl std::hash::Hash for FontDescription {
729    #[inline]
730    fn hash<H>(&self, state: &mut H)
731    where
732        H: std::hash::Hasher,
733    {
734        std::hash::Hash::hash(&self.hash(), state)
735    }
736}
737
738unsafe impl Send for FontDescription {}
739unsafe impl Sync for FontDescription {}