pango/glyph_geometry.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::fmt;
4
5glib::wrapper! {
6 /// The [`GlyphGeometry`][crate::GlyphGeometry] structure contains width and positioning
7 /// information for a single glyph.
8 ///
9 /// Note that @width is not guaranteed to be the same as the glyph
10 /// extents. Kerning and other positioning applied during shaping will
11 /// affect both the @width and the @x_offset for the glyphs in the
12 /// glyph string that results from shaping.
13 ///
14 /// The information in this struct is intended for rendering the glyphs,
15 /// as follows:
16 ///
17 /// 1. Assume the current point is (x, y)
18 /// 2. Render the current glyph at (x + x_offset, y + y_offset),
19 /// 3. Advance the current point to (x + width, y)
20 /// 4. Render the next glyph
21 #[doc(alias = "PangoGlyphGeometry")]
22 pub struct GlyphGeometry(BoxedInline<crate::ffi::PangoGlyphGeometry>);
23}
24
25impl GlyphGeometry {
26 #[inline]
27 pub fn width(&self) -> i32 {
28 self.inner.width
29 }
30
31 #[inline]
32 pub fn set_width(&mut self, width: i32) {
33 self.inner.width = width;
34 }
35
36 #[inline]
37 pub fn x_offset(&self) -> i32 {
38 self.inner.x_offset
39 }
40
41 #[inline]
42 pub fn set_x_offset(&mut self, x_offset: i32) {
43 self.inner.x_offset = x_offset;
44 }
45
46 #[inline]
47 pub fn y_offset(&self) -> i32 {
48 self.inner.y_offset
49 }
50
51 #[inline]
52 pub fn set_y_offset(&mut self, y_offset: i32) {
53 self.inner.y_offset = y_offset;
54 }
55}
56
57impl fmt::Debug for GlyphGeometry {
58 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
59 f.debug_struct("GlyphGeometry")
60 .field("x_offset", &self.x_offset())
61 .field("y_offset", &self.y_offset())
62 .field("width", &self.width())
63 .finish()
64 }
65}