juliettef / IconFontCppHeaders

C and C++ headers, C# and Python classes, Rust files and Go package for icon fonts Font Awesome, Fork Awesome, Google Material Design, Pictogrammers Material Design icons, Kenney game icons, Fontaudio, Codicons and Lucide.
zlib License
1.17k stars 148 forks source link

I use consFontAwesome.h in VS2013 +Imgui 1.50,but compile turn on error #2

Closed zhouxs1023 closed 8 years ago

zhouxs1023 commented 8 years ago

I use consFontAwesome.h in VS2013 +Imgui 1.50,but compile turn on C2065 error:u8 undeclared identifier as blow: step1: add #include "IconsFontAwesome.h" in main function; step2: ImGuiIO& io = ImGui::GetIO(); io.Fonts->AddFontDefault(); // merge in icons from Font Awesome static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 16.0f, &icons_config, icons_ranges);

step3:ImGui::Text( ICON_FA_FILE " File" );

but compile turn on C2065 error:u8 undeclared identifier as blow: qq 20160707230812

dougbinks commented 8 years ago

Visual Studio 2013 doesn't support the new C++11 string literals, so you can either upgrade to a newer version of Visual Studio or use IconsFontAwesome_c.h which provides a more backwards compatible version.

zhouxs1023 commented 8 years ago

I use IconsFontAwesome_c.h to build icon font,but crash in imgui_draw.cpp Line 1273 ==>"IM_ASSERT(font_offset >= 0);" qq 20160708122803

dougbinks commented 8 years ago

I'm not sure what's causing that. The code in the example on the readme and your code snippet (with the ImGui::Text called in the demo after the "Hello, world!" text).

I didn't notice before but the font ranges you're using are wrong - you should use:

static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };

as per the readme. However I don't think that is your problem. Can you post your code somewhere for me to take a look, and which version of ImGui are you using?

zhouxs1023 commented 8 years ago

I used imgui1.50 wip+vs2013,compile it successfully,but run exe turn on crash in imgui_draw.cpp Line 1273 ==>"IM_ASSERT(font_offset >= 0);" Later I used imgui1.48+vs2013,but run exe turn on crash in imgui_draw.cpp Line 1248 ==>"IM_ASSERT(font_offset >= 0);"

I added codes steps as blow: steip 1.add header file; qq 20160708201517 step2: add icon font code: qq 20160708201539 step3:add text in imgui windows qq 20160708201604 Additions: fontawesome-webfont.ttf qq 20160708203711 IconsFontAwesome_c.h qq 20160708203726

dougbinks commented 8 years ago

I'm taking a look at this now - it would be easier with text and not images for the code but the changes are small so should be fairly easy to work out.

dougbinks commented 8 years ago

I've done exactly those changes with ImGui Version 1.50 WIP and VS2015 and don't get the crash.

If you could check if the program crashes without the changes, that would be great. Meanwhile I'll check out an install of Visual Studio 2013 which will take a fair amount of time to do.

zhouxs1023 commented 8 years ago

May be .ttf file error,Redownload.ttf file,compile it sucessfully now,Thanks!

dougbinks commented 8 years ago

Great - I did manage to install VS2013 and this did indeed work, but glad you found the problem and solved it!