From 22fe7f23b109e6428cd05e9c1820dc26d14f0ab4 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 26 Sep 2014 01:04:31 +0100 Subject: [PATCH] OpenGL example: minor tweak for non-default font. --- examples/opengl_example/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index 6fc374a8..3007c05a 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -204,12 +204,16 @@ void InitImGui() ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); int tex_x, tex_y, tex_comp; void* tex_data = stbi_load_from_memory((const unsigned char*)png_data, (int)png_size, &tex_x, &tex_y, &tex_comp, 0); + IM_ASSERT(tex_data != NULL); #else // Custom font from filesystem io.Font = new ImBitmapFont(); - io.Font->LoadFromFile("../../extra_fonts/arial_unicode_ms_18_CJK.fnt"); + io.Font->LoadFromFile("../../extra_fonts/mplus-2m-medium_18.fnt"); + IM_ASSERT(io.Font->IsLoaded()); + int tex_x, tex_y, tex_comp; - void* tex_data = stbi_load("../../extra_fonts/arial_unicode_ms_18_CJK.png", &tex_x, &tex_y, &tex_comp, 4); + void* tex_data = stbi_load("../../extra_fonts/mplus-2m-medium_18.png", &tex_x, &tex_y, &tex_comp, 0); + IM_ASSERT(tex_data != NULL); // Automatically find white pixel from the texture we just loaded // (io.FontTexUvForWhite needs to contains UV coordinates pointing to a white pixel in order to render solid objects)