dear_imgui/fonts/
glyph.rs1use crate::sys;
7
8#[derive(Debug, Clone, Copy)]
13pub struct Glyph {
14 pub(crate) raw: sys::ImFontGlyph,
16}
17
18impl Glyph {
19 pub fn from_raw(raw: sys::ImFontGlyph) -> Self {
21 Self { raw }
22 }
23
24 pub fn codepoint(&self) -> u32 {
26 self.raw.Codepoint()
27 }
28
29 pub fn visible(&self) -> bool {
31 self.raw.Visible() != 0
32 }
33
34 pub fn advance_x(&self) -> f32 {
36 self.raw.AdvanceX
37 }
38
39 pub fn tex_coords(&self) -> ([f32; 2], [f32; 2]) {
41 ([self.raw.U0, self.raw.V0], [self.raw.U1, self.raw.V1])
42 }
43
44 pub fn position_and_size(&self) -> ([f32; 2], [f32; 2]) {
46 ([self.raw.X0, self.raw.Y0], [self.raw.X1, self.raw.Y1])
47 }
48}
49
50impl From<sys::ImFontGlyph> for Glyph {
51 fn from(raw: sys::ImFontGlyph) -> Self {
52 Self::from_raw(raw)
53 }
54}