From f93389178b117008bc9e120ad5f43eea23bb2712 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Fri, 24 Apr 2020 23:36:59 +0300 Subject: [PATCH] Handle new FontGlyph bitfields --- src/fonts/glyph.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/fonts/glyph.rs b/src/fonts/glyph.rs index e4da106..5231026 100644 --- a/src/fonts/glyph.rs +++ b/src/fonts/glyph.rs @@ -5,7 +5,7 @@ use crate::sys; #[derive(Copy, Clone, Debug, PartialEq)] #[repr(C)] pub struct FontGlyph { - pub codepoint: u16, + bitfields: u32, pub advance_x: f32, pub x0: f32, pub y0: f32, @@ -17,6 +17,21 @@ pub struct FontGlyph { pub v1: f32, } +impl FontGlyph { + pub fn codepoint(&self) -> u32 { + unsafe { self.raw().Codepoint() } + } + pub fn set_codepoint(&mut self, codepoint: u32) { + unsafe { self.raw_mut().set_Codepoint(codepoint) }; + } + pub fn visible(&self) -> bool { + unsafe { self.raw().Visible() != 0 } + } + pub fn set_visible(&mut self, visible: bool) { + unsafe { self.raw_mut().set_Visible(visible as u32) } + } +} + unsafe impl RawCast for FontGlyph {} #[test] @@ -37,7 +52,7 @@ fn test_font_glyph_memory_layout() { assert_eq!(offset_of!(FontGlyph, $l), offset_of!(ImFontGlyph, $r)); }; }; - assert_field_offset!(codepoint, Codepoint); + assert_field_offset!(bitfields, _bitfield_1); assert_field_offset!(advance_x, AdvanceX); assert_field_offset!(x0, X0); assert_field_offset!(y0, Y0);