cairo/font/
glyph.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::ffi;
4use std::fmt;
5
6#[derive(Clone, Copy)]
7#[repr(transparent)]
8#[doc(alias = "cairo_glyph_t")]
9pub struct Glyph(ffi::cairo_glyph_t);
10
11impl Glyph {
12    pub fn new(index: libc::c_ulong, x: f64, y: f64) -> Self {
13        Self(ffi::cairo_glyph_t { index, x, y })
14    }
15
16    pub fn index(&self) -> libc::c_ulong {
17        self.0.index
18    }
19
20    pub fn x(&self) -> f64 {
21        self.0.x
22    }
23
24    pub fn y(&self) -> f64 {
25        self.0.y
26    }
27
28    pub fn set_index(&mut self, index: libc::c_ulong) {
29        self.0.index = index;
30    }
31
32    pub fn set_x(&mut self, x: f64) {
33        self.0.x = x;
34    }
35
36    pub fn set_y(&mut self, y: f64) {
37        self.0.y = y;
38    }
39}
40
41impl fmt::Debug for Glyph {
42    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43        f.debug_struct("Glyph")
44            .field("index", &self.index())
45            .field("x", &self.x())
46            .field("y", &self.y())
47            .finish()
48    }
49}