From 0e1ec3cb6a7a56047e4ea2428da0cf17e2a5660c Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Sat, 5 May 2018 12:13:28 +0900 Subject: [PATCH] fonts: Use ImFontConfig_DefaultConstructor to initialize sys::ImFontConfig --- imgui-sys/src/lib.rs | 26 -------------------------- src/fonts.rs | 6 +++++- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/imgui-sys/src/lib.rs b/imgui-sys/src/lib.rs index def7037..ba670c9 100644 --- a/imgui-sys/src/lib.rs +++ b/imgui-sys/src/lib.rs @@ -15,7 +15,6 @@ extern crate glium; use std::convert::From; use std::mem; use std::os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ushort, c_void}; -use std::ptr; use std::slice; #[cfg(feature = "gfx")] @@ -911,31 +910,6 @@ pub struct ImFontConfig { name: [c_char; 32], dst_font: *mut ImFont, } -impl ImFontConfig { - // This function only exists because cimgui does not provide a wrapper around - // `ImGuiConfig::ImGuiConfig()`. This code is based off that constructor. - pub fn new() -> ImFontConfig { - ImFontConfig { - font_data: ptr::null_mut(), - font_data_size: 0, - font_data_owned_by_atlas: true, - font_no: 0, - size_pixels: 0.0, - oversample_h: 3, - oversample_v: 1, - pixel_snap_h: false, - glyph_extra_spacing: ImVec2::zero(), - glyph_offset: ImVec2::zero(), - glyph_ranges: ptr::null(), - merge_mode: false, - rasterizer_flags: 0, - rasterizer_multiply: 1.0, - - name: [0; 32], - dst_font: ptr::null_mut(), - } - } -} #[repr(C)] #[derive(Copy, Clone, Debug, Default)] diff --git a/src/fonts.rs b/src/fonts.rs index e5c0aae..a3023b7 100644 --- a/src/fonts.rs +++ b/src/fonts.rs @@ -156,7 +156,11 @@ impl ImFontConfig { } fn make_config(self) -> sys::ImFontConfig { - let mut config = sys::ImFontConfig::new(); + let mut config = unsafe { + let mut config = mem::uninitialized(); + sys::ImFontConfig_DefaultConstructor(&mut config); + config + }; config.size_pixels = self.size_pixels; config.oversample_h = self.oversample_h as c_int; config.oversample_v = self.oversample_v as c_int;