inkyblackness / imgui-go

Go wrapper library for "Dear ImGui" (https://github.com/ocornut/imgui)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: Assertion failed! Expression: font && font->IsLoaded()

neclepsio opened this issue · comments

After a refactoring my application crashes if I use glyph ranges.

This code works:

    id := imgui.CurrentIO().Fonts().AddFontFromMemoryTTFV(
        data,
        size,
        imgui.DefaultFontConfig,
        0)

While this crashes:

    var builder imgui.GlyphRangesBuilder
    builder.Add(0x00, 0xff)
    glyphRange := builder.Build()
    //defer glyphRange.Free()
    
    id := imgui.CurrentIO().Fonts().AddFontFromMemoryTTFV(
        data,
        size,
        imgui.DefaultFontConfig,
        glyphRange.GlyphRanges)

The crash is later when I try to use the font:

    panic: Assertion failed!
    File: [...]\pkg\mod\github.com\inkyblackness\imgui-go\v4@v4.1.0\imgui/imgui.cpp, Line 6420
    
    Expression: font && font->IsLoaded()

I inspected what is pointed by glyphRange.GlyphRanges and it seems to be fine. I tried disabling GC with no result.

I cannot find anything in the docs pointing to an incorrect usage. Do you have any suggestion to what I should check?

Sorry, the range should have been 0x20-0xff. Starting with 0 meant no range.