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