pango/
glyph_geometry.rs

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
// Take a look at the license at the top of the repository in the LICENSE file.

use std::fmt;

glib::wrapper! {
    /// The [`GlyphGeometry`][crate::GlyphGeometry] structure contains width and positioning
    /// information for a single glyph.
    ///
    /// Note that @width is not guaranteed to be the same as the glyph
    /// extents. Kerning and other positioning applied during shaping will
    /// affect both the @width and the @x_offset for the glyphs in the
    /// glyph string that results from shaping.
    ///
    /// The information in this struct is intended for rendering the glyphs,
    /// as follows:
    ///
    /// 1. Assume the current point is (x, y)
    /// 2. Render the current glyph at (x + x_offset, y + y_offset),
    /// 3. Advance the current point to (x + width, y)
    /// 4. Render the next glyph
    #[doc(alias = "PangoGlyphGeometry")]
    pub struct GlyphGeometry(BoxedInline<crate::ffi::PangoGlyphGeometry>);
}

impl GlyphGeometry {
    #[inline]
    pub fn width(&self) -> i32 {
        self.inner.width
    }

    #[inline]
    pub fn set_width(&mut self, width: i32) {
        self.inner.width = width;
    }

    #[inline]
    pub fn x_offset(&self) -> i32 {
        self.inner.x_offset
    }

    #[inline]
    pub fn set_x_offset(&mut self, x_offset: i32) {
        self.inner.x_offset = x_offset;
    }

    #[inline]
    pub fn y_offset(&self) -> i32 {
        self.inner.y_offset
    }

    #[inline]
    pub fn set_y_offset(&mut self, y_offset: i32) {
        self.inner.y_offset = y_offset;
    }
}

impl fmt::Debug for GlyphGeometry {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("GlyphGeometry")
            .field("x_offset", &self.x_offset())
            .field("y_offset", &self.y_offset())
            .field("width", &self.width())
            .finish()
    }
}