pango/auto/font_metrics.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::translate::*;
7
8glib::wrapper! {
9 /// /picture
10 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11 pub struct FontMetrics(Shared<ffi::PangoFontMetrics>);
12
13 match fn {
14 ref => |ptr| ffi::pango_font_metrics_ref(ptr),
15 unref => |ptr| ffi::pango_font_metrics_unref(ptr),
16 type_ => || ffi::pango_font_metrics_get_type(),
17 }
18}
19
20impl FontMetrics {
21 /// Gets the approximate character width for a font metrics structure.
22 ///
23 /// This is merely a representative value useful, for example, for
24 /// determining the initial size for a window. Actual characters in
25 /// text will be wider and narrower than this.
26 ///
27 /// # Returns
28 ///
29 /// the character width, in Pango units.
30 #[doc(alias = "pango_font_metrics_get_approximate_char_width")]
31 #[doc(alias = "get_approximate_char_width")]
32 pub fn approximate_char_width(&self) -> i32 {
33 unsafe { ffi::pango_font_metrics_get_approximate_char_width(self.to_glib_none().0) }
34 }
35
36 /// Gets the approximate digit width for a font metrics structure.
37 ///
38 /// This is merely a representative value useful, for example, for
39 /// determining the initial size for a window. Actual digits in
40 /// text can be wider or narrower than this, though this value
41 /// is generally somewhat more accurate than the result of
42 /// pango_font_metrics_get_approximate_char_width() for digits.
43 ///
44 /// # Returns
45 ///
46 /// the digit width, in Pango units.
47 #[doc(alias = "pango_font_metrics_get_approximate_digit_width")]
48 #[doc(alias = "get_approximate_digit_width")]
49 pub fn approximate_digit_width(&self) -> i32 {
50 unsafe { ffi::pango_font_metrics_get_approximate_digit_width(self.to_glib_none().0) }
51 }
52
53 /// Gets the ascent from a font metrics structure.
54 ///
55 /// The ascent is the distance from the baseline to the logical top
56 /// of a line of text. (The logical top may be above or below the top
57 /// of the actual drawn ink. It is necessary to lay out the text to
58 /// figure where the ink will be.)
59 ///
60 /// # Returns
61 ///
62 /// the ascent, in Pango units.
63 #[doc(alias = "pango_font_metrics_get_ascent")]
64 #[doc(alias = "get_ascent")]
65 pub fn ascent(&self) -> i32 {
66 unsafe { ffi::pango_font_metrics_get_ascent(self.to_glib_none().0) }
67 }
68
69 /// Gets the descent from a font metrics structure.
70 ///
71 /// The descent is the distance from the baseline to the logical bottom
72 /// of a line of text. (The logical bottom may be above or below the
73 /// bottom of the actual drawn ink. It is necessary to lay out the text
74 /// to figure where the ink will be.)
75 ///
76 /// # Returns
77 ///
78 /// the descent, in Pango units.
79 #[doc(alias = "pango_font_metrics_get_descent")]
80 #[doc(alias = "get_descent")]
81 pub fn descent(&self) -> i32 {
82 unsafe { ffi::pango_font_metrics_get_descent(self.to_glib_none().0) }
83 }
84
85 /// Gets the line height from a font metrics structure.
86 ///
87 /// The line height is the recommended distance between successive
88 /// baselines in wrapped text using this font.
89 ///
90 /// If the line height is not available, 0 is returned.
91 ///
92 /// # Returns
93 ///
94 /// the height, in Pango units
95 #[cfg(feature = "v1_44")]
96 #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
97 #[doc(alias = "pango_font_metrics_get_height")]
98 #[doc(alias = "get_height")]
99 pub fn height(&self) -> i32 {
100 unsafe { ffi::pango_font_metrics_get_height(self.to_glib_none().0) }
101 }
102
103 /// Gets the suggested position to draw the strikethrough.
104 ///
105 /// The value returned is the distance *above* the
106 /// baseline of the top of the strikethrough.
107 ///
108 /// # Returns
109 ///
110 /// the suggested strikethrough position, in Pango units.
111 #[doc(alias = "pango_font_metrics_get_strikethrough_position")]
112 #[doc(alias = "get_strikethrough_position")]
113 pub fn strikethrough_position(&self) -> i32 {
114 unsafe { ffi::pango_font_metrics_get_strikethrough_position(self.to_glib_none().0) }
115 }
116
117 /// Gets the suggested thickness to draw for the strikethrough.
118 ///
119 /// # Returns
120 ///
121 /// the suggested strikethrough thickness, in Pango units.
122 #[doc(alias = "pango_font_metrics_get_strikethrough_thickness")]
123 #[doc(alias = "get_strikethrough_thickness")]
124 pub fn strikethrough_thickness(&self) -> i32 {
125 unsafe { ffi::pango_font_metrics_get_strikethrough_thickness(self.to_glib_none().0) }
126 }
127
128 /// Gets the suggested position to draw the underline.
129 ///
130 /// The value returned is the distance *above* the baseline of the top
131 /// of the underline. Since most fonts have underline positions beneath
132 /// the baseline, this value is typically negative.
133 ///
134 /// # Returns
135 ///
136 /// the suggested underline position, in Pango units.
137 #[doc(alias = "pango_font_metrics_get_underline_position")]
138 #[doc(alias = "get_underline_position")]
139 pub fn underline_position(&self) -> i32 {
140 unsafe { ffi::pango_font_metrics_get_underline_position(self.to_glib_none().0) }
141 }
142
143 /// Gets the suggested thickness to draw for the underline.
144 ///
145 /// # Returns
146 ///
147 /// the suggested underline thickness, in Pango units.
148 #[doc(alias = "pango_font_metrics_get_underline_thickness")]
149 #[doc(alias = "get_underline_thickness")]
150 pub fn underline_thickness(&self) -> i32 {
151 unsafe { ffi::pango_font_metrics_get_underline_thickness(self.to_glib_none().0) }
152 }
153}