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
// Take a look at the license at the top of the repository in the LICENSE file.
use std::fmt;
#[derive(Clone, Copy)]
#[repr(transparent)]
#[doc(alias = "cairo_text_cluster_t")]
pub struct TextCluster(ffi::cairo_text_cluster_t);
impl TextCluster {
pub fn new(num_bytes: i32, num_glyphs: i32) -> Self {
Self(ffi::cairo_text_cluster_t {
num_bytes,
num_glyphs,
})
}
pub fn num_bytes(&self) -> i32 {
self.0.num_bytes
}
pub fn num_glyphs(&self) -> i32 {
self.0.num_glyphs
}
pub fn set_num_bytes(&mut self, num_bytes: i32) {
self.0.num_bytes = num_bytes;
}
pub fn set_num_glyphs(&mut self, num_glyphs: i32) {
self.0.num_glyphs = num_glyphs;
}
}
impl fmt::Debug for TextCluster {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TextCluster")
.field("num_bytes", &self.num_bytes())
.field("num_glyphs", &self.num_glyphs())
.finish()
}
}