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
use std::fmt;
#[derive(Clone, Copy)]
#[repr(transparent)]
#[doc(alias = "cairo_font_extents_t")]
pub struct FontExtents(ffi::cairo_font_extents_t);
impl FontExtents {
pub fn ascent(&self) -> f64 {
self.0.ascent
}
pub fn descent(&self) -> f64 {
self.0.descent
}
pub fn height(&self) -> f64 {
self.0.height
}
pub fn max_x_advance(&self) -> f64 {
self.0.max_x_advance
}
pub fn max_y_advance(&self) -> f64 {
self.0.max_y_advance
}
pub fn set_ascent(&mut self, ascent: f64) {
self.0.ascent = ascent;
}
pub fn set_descent(&mut self, descent: f64) {
self.0.descent = descent;
}
pub fn set_height(&mut self, height: f64) {
self.0.height = height;
}
pub fn set_max_x_advance(&mut self, max_x_advance: f64) {
self.0.max_x_advance = max_x_advance;
}
pub fn set_max_y_advance(&mut self, max_y_advance: f64) {
self.0.max_y_advance = max_y_advance;
}
}
impl fmt::Debug for FontExtents {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FontExtents")
.field("ascent", &self.ascent())
.field("descent", &self.descent())
.field("height", &self.height())
.field("max_x_advance", &self.max_x_advance())
.field("max_y_advance", &self.max_y_advance())
.finish()
}
}
#[doc(hidden)]
impl From<FontExtents> for ffi::cairo_font_extents_t {
fn from(val: FontExtents) -> ffi::cairo_font_extents_t {
val.0
}
}
#[doc(hidden)]
impl From<ffi::cairo_font_extents_t> for FontExtents {
fn from(value: ffi::cairo_font_extents_t) -> Self {
Self(value)
}
}