Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash with Font #951

Closed
sonoro1234 opened this issue Dec 24, 2016 · 10 comments
Closed

crash with Font #951

sonoro1234 opened this issue Dec 24, 2016 · 10 comments

Comments

@sonoro1234
Copy link

Hello Omar,

If I use:

imgui.ImGui_ImplGlfwGL3_Init(self.window, false);
imgui.ImFontAtlas_AddFontFromFileTTF(imgui.igGetIO().Fonts, [[C:\luaGL\ProggyTiny.ttf]], 10, nil, nil)

I am getting crashes so I did gdb with Debug and RelWithDebInfo:

--Debug version

Program: C:\luaGL\luajit.exe
File: C:\luaGL\gitsources\cimgui\imgui\imgui_draw.cpp, Line 1278

Expression: font_offset >= 0

This application has requested the Runtime to terminate it in an unusual way.

--RelWithDebInfo

Program received signal SIGSEGV, Segmentation fault.
SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636
4636        g.FontTexUvWhitePixel = g.Font->ContainerAtlas->TexUvWhitePixel;


Thread 1 (Thread 4812.0xa24):
#0  SetCurrentFont (font=0x3be170) at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:4636
#1  0x6bd13a66 in ImGui::NewFrame () at C:\luaGL\gitsources\cimgui\imgui\imgui.cpp:2142
#2  0x6bd4066b in ImGui_ImplGlfwGL3_NewFrame ()
    at C:\luaGL\gitsources\cimgui\extras\impl_glfw3\imgui_impl_glfw_gl3.cpp:401
#3  0x66d84bb2 in ?? () from C:\luaGL\lua51.dll

but I am not able to make conclusions.
1278 is ImFontAtlas::Build()

Thanks

@ocornut
Copy link
Owner

ocornut commented Dec 24, 2016 via email

@sonoro1234
Copy link
Author

Filename is ok in Lua and ImFontAtlas_AddFontFromFileTTF returns not null.
Are asserts enabled building for Debug?

@ocornut
Copy link
Owner

ocornut commented Dec 24, 2016 via email

@sonoro1234
Copy link
Author

I could check that the pointer in SetCurrentFont is the same returned from ImFontAtlas_AddFontFromFileTTF

@sonoro1234
Copy link
Author

ProggyTiny.ttf is from extra_fonts

@sonoro1234
Copy link
Author

Also : there are two gdb traces, one for Debug the other for Release with debug information

@ocornut
Copy link
Owner

ocornut commented Dec 24, 2016 via email

@sonoro1234
Copy link
Author

(gdb) print cfg
$1 = (ImFontConfig &) @0x5fe4b8: {FontData = 0x3ac0048, FontDataSize = 68677, FontDataOwnedByAtlas = true,
  FontNo = 0, SizePixels = 10, OversampleH = 3, OversampleV = 1, PixelSnapH = false, GlyphExtraSpacing = {
    x = 0, y = 0}, GlyphRanges = 0x0, MergeMode = false, MergeGlyphCenterV = false,
  Name = "ProggyTiny.ttf, 10px", '\000' <repeats 11 times>, DstFont = 0x5fe170}

@sonoro1234
Copy link
Author

A lot of noise for: Fake ProggyTiny.ttf
It was an html file saved with that name!!
(inspecting the data in the debugger revealed it)
Everything works now
Sorry

@ocornut
Copy link
Owner

ocornut commented Dec 31, 2016

Your assert should really crash/halt your application, this is what asserts are for.
I can silently fail or keep returning error codes but it'll have to fail at some point (main loop needs at least one valid font).

ocornut added a commit that referenced this issue Oct 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants