pangocairo/auto/font_map.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 crate::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// [`FontMap`][crate::FontMap] is an interface exported by font maps for
10 /// use with Cairo.
11 ///
12 /// The actual type of the font map will depend on the particular
13 /// font technology Cairo was compiled to use.
14 ///
15 /// # Implements
16 ///
17 /// [`PangoCairoFontMapExt`][trait@crate::prelude::PangoCairoFontMapExt], [`trait@pango::prelude::FontMapExt`], [`PangoCairoFontMapExtManual`][trait@crate::prelude::PangoCairoFontMapExtManual]
18 #[doc(alias = "PangoCairoFontMap")]
19 pub struct FontMap(Interface<ffi::PangoCairoFontMap>) @requires pango::FontMap;
20
21 match fn {
22 type_ => || ffi::pango_cairo_font_map_get_type(),
23 }
24}
25
26impl FontMap {
27 pub const NONE: Option<&'static FontMap> = None;
28
29 /// Gets a default [`FontMap`][crate::FontMap] to use with Cairo.
30 ///
31 /// Note that the type of the returned object will depend on the
32 /// particular font backend Cairo was compiled to use; you generally
33 /// should only use the [`pango::FontMap`][crate::pango::FontMap] and [`FontMap`][crate::FontMap]
34 /// interfaces on the returned object.
35 ///
36 /// The default Cairo fontmap can be changed by using
37 /// [`PangoCairoFontMapExtManual::set_default()`][crate::prelude::PangoCairoFontMapExtManual::set_default()]. This can be used to
38 /// change the Cairo font backend that the default fontmap uses
39 /// for example.
40 ///
41 /// Note that since Pango 1.32.6, the default fontmap is per-thread.
42 /// Each thread gets its own default fontmap. In this way, PangoCairo
43 /// can be used safely from multiple threads.
44 ///
45 /// # Returns
46 ///
47 /// the default PangoCairo fontmap
48 /// for the current thread. This object is owned by Pango and must
49 /// not be freed.
50 #[doc(alias = "pango_cairo_font_map_get_default")]
51 #[doc(alias = "get_default")]
52 #[allow(clippy::should_implement_trait)]
53 pub fn default() -> pango::FontMap {
54 unsafe { from_glib_none(ffi::pango_cairo_font_map_get_default()) }
55 }
56}
57
58mod sealed {
59 pub trait Sealed {}
60 impl<T: super::IsA<super::FontMap>> Sealed for T {}
61}
62
63/// Trait containing all [`struct@FontMap`] methods.
64///
65/// # Implementors
66///
67/// [`FontMap`][struct@crate::FontMap]
68pub trait PangoCairoFontMapExt: IsA<FontMap> + sealed::Sealed + 'static {
69 /// Gets the resolution for the fontmap.
70 ///
71 /// See [`set_resolution()`][Self::set_resolution()].
72 ///
73 /// # Returns
74 ///
75 /// the resolution in "dots per inch"
76 #[doc(alias = "pango_cairo_font_map_get_resolution")]
77 #[doc(alias = "get_resolution")]
78 fn resolution(&self) -> f64 {
79 unsafe { ffi::pango_cairo_font_map_get_resolution(self.as_ref().to_glib_none().0) }
80 }
81
82 /// Sets the resolution for the fontmap.
83 ///
84 /// This is a scale factor between
85 /// points specified in a `PangoFontDescription` and Cairo units. The
86 /// default value is 96, meaning that a 10 point font will be 13
87 /// units high. (10 * 96. / 72. = 13.3).
88 /// ## `dpi`
89 /// the resolution in "dots per inch". (Physical inches aren't actually
90 /// involved; the terminology is conventional.)
91 #[doc(alias = "pango_cairo_font_map_set_resolution")]
92 fn set_resolution(&self, dpi: f64) {
93 unsafe {
94 ffi::pango_cairo_font_map_set_resolution(self.as_ref().to_glib_none().0, dpi);
95 }
96 }
97}
98
99impl<O: IsA<FontMap>> PangoCairoFontMapExt for O {}