mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-09 23:54:20 +00:00
Fonts: added comment about the classic AddFontFromMemoryTTF() issue. (#9067, #6916, #6781, #5330, #4307, #2042, #2029, #1734, #1259, #220)
This commit is contained in:
parent
e60e5bff63
commit
d246850787
1 changed files with 5 additions and 0 deletions
|
|
@ -3633,6 +3633,11 @@ void ImFontAtlasFontSourceAddToFont(ImFontAtlas* atlas, ImFont* font, ImFontConf
|
|||
void ImFontAtlasFontDestroySourceData(ImFontAtlas* atlas, ImFontConfig* src)
|
||||
{
|
||||
IM_UNUSED(atlas);
|
||||
// IF YOU GET A CRASH IN THE IM_FREE() CALL HERE AND USED AddFontFromMemoryTTF():
|
||||
// - DUE TO LEGACY REASON AddFontFromMemoryTTF() TRANSFERS MEMORY OWNERSHIP BY DEFAULT.
|
||||
// - IT WILL THEREFORE CRASH WHEN PASSED DATA WHICH MAY NOT BE FREEED BY IMGUI.
|
||||
// - USE `ImFontConfig font_cfg; font_cfg.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryTTF(....., &cfg);` to disable passing ownership/
|
||||
// WE WILL ADDRESS THIS IN A FUTURE REWORK OF THE API.
|
||||
if (src->FontDataOwnedByAtlas)
|
||||
IM_FREE(src->FontData);
|
||||
src->FontData = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue