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