ImGui frees atlas-owned font data with IM_FREE, so the mutable copy the API wants must come from ImGui's own allocator; this replaces passing the embedded const arrays through const_cast with ownership disabled.
| 42 | // API wants must come from ImGui's own allocator; this replaces passing |
| 43 | // the embedded const arrays through const_cast with ownership disabled. |
| 44 | void* imgui_owned_font_copy(const unsigned char* data, const std::size_t size) { |
| 45 | void* copy = ImGui::MemAlloc(size); |
| 46 | IM_ASSERT(copy != nullptr); |
| 47 | std::memcpy(copy, data, size); |
| 48 | return copy; |
| 49 | } |
| 50 | |
| 51 | } // namespace |
| 52 |