cairo/font/
text_cluster.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_text_cluster_t")]
9pub struct TextCluster(ffi::cairo_text_cluster_t);
10
11impl TextCluster {
12    pub fn new(num_bytes: i32, num_glyphs: i32) -> Self {
13        Self(ffi::cairo_text_cluster_t {
14            num_bytes,
15            num_glyphs,
16        })
17    }
18
19    pub fn num_bytes(&self) -> i32 {
20        self.0.num_bytes
21    }
22
23    pub fn num_glyphs(&self) -> i32 {
24        self.0.num_glyphs
25    }
26
27    pub fn set_num_bytes(&mut self, num_bytes: i32) {
28        self.0.num_bytes = num_bytes;
29    }
30
31    pub fn set_num_glyphs(&mut self, num_glyphs: i32) {
32        self.0.num_glyphs = num_glyphs;
33    }
34}
35
36impl fmt::Debug for TextCluster {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        f.debug_struct("TextCluster")
39            .field("num_bytes", &self.num_bytes())
40            .field("num_glyphs", &self.num_glyphs())
41            .finish()
42    }
43}